`--squash`和`--no-ff --no-commit`之间有什么区别? [英] What are the differences between `--squash` and `--no-ff --no-commit`?

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

问题描述



git merge --squash 的唯一区别,和 git merge --no-ff --no-commit 否认其他父母?

解决方案

差异



您的存储库结束了不同。



让我们假设您在主题分支上完成开发之后,您的存储库就像这样:





- squash



如果您签出master,然后 git merge --squash topic; git commit -m topic ,你得到这个:



$ b

- no-ff --no-commit



相反,如果你做 git merge --no-ff --no-commit;



如果你真的想要的话,你可以使用它来创建你自己的微型提交。隐藏(我的意思是从存储库中删除)你的微提交,使用 - squash 。因为,正如你在上面的图片中看到的,如果你不挤压你的话,你并不是真的隐藏你的微型提交。而且,你通常不会将主题分支推向世界。如果您希望您的历史记录具备所有微型提交,但将它们留在另一个开发线中(绿色线条在上面的图片),使用 - no-ff --no-commit 。但请记住,a)这不是一个分支,并且b)在Git中并不意味着任何东西,因为它只是您提交的另一个父代。



请参阅 Git分支 - 分支是什么如果你真的很想明白。


Which one should one use to hide microcommits?

Is the only difference between git merge --squash and git merge --no-ff --no-commit the denial of the other parents?

解决方案

The differences

These options exists for separate purposes. Your repository ends up differently.

Let's suppose that your repository is like this after you are done developing on the topic branch:

--squash

If you checkout master and then git merge --squash topic; git commit -m topic, you get this:

--no-ff --no-commit

Instead, if you do git merge --no-ff --no-commit; git commit -m topic, you get this:

Hiding micro-commits

If you really want to hide (I mean delete from your repository) your micro-commits, use --squash. Because, as you can see in the above images, you are not really hiding your micro-commits if you do not squash. Moreover, you do not usually push your topic branches to the world. Topic branches are for topic to get mature.

If you want your history to have all your micro-commits, but leave them in another line of development (the green line in the above images), use --no-ff --no-commit. But please remember that a) this is not a branch, and b) does not really mean anything in Git because it is just another parent of your commit.

Please refer to Git Branching - What a Branch Is if you really want to understand.

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

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