0

寻求帮助以清理我的分支。我削减了太多小修复的工作,并且我对这些修复有太多的合并master。我想将我的修复收集到一个更大的修复分支。由此:

(C0)<----(C1)<----(C2)<----(C3)   master
           \      / \      /
            \(F1)/   \(F2)/

    C2, C3 - merges from small fixes

对此:

(C0)<----(C1)<------------(C4')   master
           \               /
            \(F1)<----(F2)/

有可能这样做吗?

4

2 回答 2

1

可以做你想做的事,但请记住,如果其他人master与你共享分支,并且他们已经拥有历史的旧版本,并且他们已经在它之上做了更多的工作(提交),那么您将迫使他们必须将他们的工作与新历史重新同步。

请执行下列操作:

git checkout -b new-branch F1
git cherry-pick F2
git checkout master
git reset --hard C1
git merge --no-ff new-branch

# If you need to push to a remote, you'll need to force push
# if the old history was already pushed:
git push <remote> head --force
于 2013-09-08T17:58:04.117 回答
0

如果F1在 branchfeature-aF2in 中feature-b,则应执行以下操作:

git checkout feature-b
git rebase feature-a
git checkout feature-a
git merge-feature-b

它重新调整所有补丁,feature-b然后feature-a进行快进合并以将这些提交包含在feature-b分支中。

现在您可以删除过时的 feature-b 分支,因为现在 feature-a 包含其所有提交

git branch -d feature-b
于 2013-09-08T18:30:18.980 回答