git merge使用(--no-ff)

帮助文档

git help merge
或者
git merge --help

会在默认浏览器中打开相关的帮助文档

常用命令

案例:当前分支在develop上,将develop分支merge到master分支

git checkout master
git pull
git merge --no-commit --no-ff develop

参数介绍:
–no-commit
执行merge操作,它可以防止合并失败同时不会自动提交,它给了用户一个机会在提交前去检查并进一步调整提交结果。

–no-ff
官方解释:

–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.

推荐使用 --no-ff 的方式(非 fast-forwad 快速合并),会创建一个新的合并提交记录,更容易查看git历史记录。
注意:
在git bash中做git merge操作执行后,一般会进入vim编辑状态,用来编辑新的合并的comments。可以参考:

vim 操作

发布了79 篇原创文章 · 获赞 10 · 访问量 8668

猜你喜欢

转载自blog.csdn.net/weixin_44728363/article/details/102964700