Git顺序合并发散分支

时间:2016-06-21 21:08:02

标签: git

我的本​​地分支someNewFeature错误地分歧了。

运行git状态,显示:

$ git status                     
On branch someNewFeature
Your branch and 'origin/someNewFeature' have diverged,
and have 8 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean

本地分支的git commit树如下所示:

* jjjjjjj commit 10
* iiiiiii commit 9
* hhhhhhh commit 8
* ggggggg commit 7
* fffffff commit 6
* eeeeeee commit 5
* ddddddd commit 4
* ccccccc commit 3
| * bbbbbbb Diverged commit
|/  
* aaaaaaa Base commit

我想通过顺序应用所有提交来解决分歧,即它应该如下所示:

* jjjjjjj commit 10
* iiiiiii commit 9
* hhhhhhh commit 8
* ggggggg commit 7
* fffffff commit 6
* eeeeeee commit 5
* ddddddd commit 4
* ccccccc commit 3
* bbbbbbb Diverged commit 
* aaaaaaa Base commit

奖金:如果你能猜到我是怎么做到的,我会很感激这种见解。

2 个答案:

答案 0 :(得分:1)

您是否尝试过简单的git rebase someNewFeature origin/someNewFeature

答案 1 :(得分:1)

如果您害怕搞乱您的存储库并且不确定您的git命令,我建议GitUp使用git存储库。它通过可视化具有所有合并/变基功能。它还具有撤消/重做功能,所以如果你搞砸了什么,你总是可以恢复。您甚至可以重新订购提交。

这里还有一个CLI答案:据我所知,你有一个名为someNewFeature的本地分支,你正在进行近8次提交。但在远程分支上,其他一些开发人员推动了一些变化。并且您希望获得它们并重新应用您的更改。为此,您可以在someNewFeature分支中运行此命令:

git pull --rebase origin someNewFeature