将多个非连续提交移动到不同的分支
Move multiple non-consecutive commits to different branch
我有两个分支(目前)不应该直接合并在一起。但是,我需要将两个不同的非连续提交从一个分支移动到另一个分支。我目前有:
top-branch:
A-B-C-D
bottom-branch:
X-Y
我想得到:
top-branch:
A-C
bottom-branch:
X-Y-B-D
假设您从与此类似的情况开始:
> git log --oneline --graph --all --decorate=short
* e08a53c (HEAD, bottom-branch) Y
* b659a43 X
| * 88612b2 (top-branch) D
| * 8b37e26 C
| * afe4ffd B
| * 5bc157c A
|/
* e3c7a2d other commit
我将从分支 bottom-branch
开始挑选您需要的两个提交
git cherry-pick afe4ffd
然后返回top-branch
并进行交互式变基以删除您不需要的两个提交
git rebase -i HEAD~4
我有两个分支(目前)不应该直接合并在一起。但是,我需要将两个不同的非连续提交从一个分支移动到另一个分支。我目前有:
top-branch:
A-B-C-D
bottom-branch:
X-Y
我想得到:
top-branch:
A-C
bottom-branch:
X-Y-B-D
假设您从与此类似的情况开始:
> git log --oneline --graph --all --decorate=short
* e08a53c (HEAD, bottom-branch) Y
* b659a43 X
| * 88612b2 (top-branch) D
| * 8b37e26 C
| * afe4ffd B
| * 5bc157c A
|/
* e3c7a2d other commit
我将从分支 bottom-branch
开始挑选您需要的两个提交
git cherry-pick afe4ffd
然后返回top-branch
并进行交互式变基以删除您不需要的两个提交
git rebase -i HEAD~4