Git merge 没有合并,只是将所有提交添加到 master
Git merge did not merge, just added all commits to master
我将一个分支合并回 master 并且没有合并提交,来自另一个分支的所有提交现在看起来就像提交给 master 一样。
我做了什么:
在 SourceTree 中,我选择了 master,选择了 merge,选择了最近的提交并将其合并。它表明我需要推动我的 39 次提交,所以我做到了。才发现原来没有merge commit
我怎样才能扭转这种局面?令人尴尬的是,这些提交显示得好像它们都已掌握。
如果无需合并提交就可以合并分支,则默认情况下会这样做。这被称为 "fast forward",并且 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.
我将一个分支合并回 master 并且没有合并提交,来自另一个分支的所有提交现在看起来就像提交给 master 一样。
我做了什么:
在 SourceTree 中,我选择了 master,选择了 merge,选择了最近的提交并将其合并。它表明我需要推动我的 39 次提交,所以我做到了。才发现原来没有merge commit
我怎样才能扭转这种局面?令人尴尬的是,这些提交显示得好像它们都已掌握。
如果无需合并提交就可以合并分支,则默认情况下会这样做。这被称为 "fast forward",并且 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.