Git merge --squash和--no-commit之间的区别 [英] Differences between Git merge --squash and --no-commit

查看:2554
本文介绍了Git merge --squash和--no-commit之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我并不清楚 git merge --squash 和a git merge --no-提交



据我了解 git merge 的帮助页面,两个命令会让我进入更新的工作树,在那里仍然可以编辑,然后做最后的提交(或多个提交)。



有人可以澄清这两种选择的区别?何时使用一个而不是另一个?

解决方案

  git merge --no-提交

这与普通合并类似,但不会创建合并提交。这个提交将是一个合并提交:当你查看历史记录时,你的提交将以普通合并的形式出现。

  git merge --squash 

这会将更改合并到工作树中,而不创建合并提交。当您提交合并的更改时,它将看起来像您的分支上新的正常提交:没有历史合并提交。这几乎就像你在所有合并的变更中做了一个樱桃选择。


As the title says, I am not really clear about the differences between a git merge --squash and a git merge --no-commit.

As far as I understand the help page for git merge, both commands would leave me in an updated working-tree, where it is still possible to edit and then to do a final commit (or multiple commits).

Could someone clarify the differences of those 2 options? When would I use one instead of the other?

解决方案

git merge --no-commit

This is just like a normal merge but doesn't create a merge-commit. This commit will be a merge commit: when you look at the history, your commit will appear as a normal merge.

git merge --squash

This will merge the changes into your working tree without creating a merge commit. When you commit the merged changes, it will look like a new "normal" commit on your branch: without a merge commit in the history. It's almost like you did a cherry-pick on all the merged changes.

这篇关于Git merge --squash和--no-commit之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆