合并不同分支上的多个提交

Merge multiple commits on different branches

我在这里向一个开源项目提交了几个拉取请求:

https://github.com/nodejs/node/pulls

它们每个都非常小,有人要求我将它们全部合并到一个 pull request 中。

我这里有一个分支,有几个分支需要合并。

https://github.com/reggi/node/branches/yours

这个命令是最好的方法吗?

git merge --squash origin/patch-1 origin/patch-3 origin/patch-4 origin/patch-5 origin/patch-6 origin/patch-7 origin/patch-8 origin/patch-9 origin/patch-10 origin/patch-11 origin/patch-12 origin/patch-13

如何合并所有这些更改?

您可以分三步完成:

  1. git checkout master
  2. git merge [list of your patch-branches]
  3. git rebase -i [ref to the first commit in master before any commits from your branches]

在第三步中,您应该为除第一步之外的所有提交检查 'squash' 选项。

我强烈建议您在尝试 git 变基之前创建您的存储库的备份。 :)