Git merge没有合并,只是将所有提交添加到master

时间:2017-01-09 20:54:47

标签: git merge atlassian-sourcetree

我将一个分支合并回master并且没有合并提交,来自另一个分支的所有提交现在看起来好像它们已经提交到master。

我做了什么:

在SourceTree中,我选择了master,选择了merge,选择了最近的提交并合并了它。它表明我需要推动我的39次提交,所以我做了。只有这样我才意识到没有合并提交。

我该怎么扭转这个?令人尴尬的是,这些提交显示好像他们都掌握了所有这些。

1 个答案:

答案 0 :(得分:2)

如果可以在没有合并提交的情况下合并分支,则默认为这样做。这被称为"快进#34;并且HEAD标记被简单地移动到新提交。没有生成新的提交。

如果您不想这样做,可以使用--no-ff强制进行合并提交。

git merge --no-ff <refspec>

来自git-merge手册页:

   --ff
       When the merge resolves as a fast-forward, only update the branch
       pointer, without creating a merge commit. This is the default
       behavior.

   --no-ff
       Create a merge commit even when the merge resolves as a
       fast-forward. This is the default behaviour when merging an
       annotated (and possibly signed) tag.

   --ff-only
       Refuse to merge and exit with a non-zero status unless the current
       HEAD is already up-to-date or the merge can be resolved as a
       fast-forward.