我应该什么时候使用git pull --rebase? [英] When should I use git pull --rebase?

查看:98
本文介绍了我应该什么时候使用git pull --rebase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有些人在默认情况下使用 git pull --rebase ,其他人坚持不使用它。我相信我理解合并和重新绑定之间的区别,但我试图将其放在 git pull 的上下文中。是否只是不想看到大量的合并提交消息,或者是否还有其他问题?

解决方案

您应该使用 git pull --rebase when




  • 您的更改不应该有单独的分支
  • >


的确 - 为什么不呢?更清楚的是,在您的提交中不会强制实施逻辑分组




好的,我想这需要一些澄清。在Git中,你可能知道,你被鼓励分支和合并。你所在的本地分支和远程分支实际上是不同的分支, git pull 是关于合并它们的。这是合理的,因为你推动的不是很经常,并且通常会在构成一个完整的功能之前积累许多变化。

然而,有时 - 无论出于何种原因 - 你认为如果这两个 - 远程和本地 - 是一个分支,它实际上会更好。就像在SVN中一样。在这里 git pull --rebase 进场了。您不再合并 - 您实际上在远程分支之上提交 。这就是它的实际情况。



无论危险与否,您是否将本地和远程分支视为一个不可分割的事物。有时候这是合理的(当你的变化很小,或者如果你在一个强大的开发的开始,当小的提交引入重要的变化时)。有时候不是(当你通常创建另一个分支时,你却懒得这么做)。但这是一个不同的问题。


I know of some people who use git pull --rebase by default and others who insist never to use it. I believe I understand the difference between merging and rebasing, but I'm trying to put this in the context of git pull. Is it just about not wanting to see lots of merge commit messages, or are there other issues?

解决方案

You should use git pull --rebase when

  • your changes do not deserve a separate branch

Indeed -- why not then? It's more clear, and doesn't impose a logical grouping on your commits.


Ok, I suppose it needs some clarification. In Git, as you probably know, you're encouraged to branch and merge. Your local branch, into which you pull changes, and remote branch are, actually, different branches, and git pull is about merging them. It's reasonable, since you push not very often and usually accumulate a number of changes before they constitute a completed feature.

However, sometimes--by whatever reason--you think that it would actually be better if these two--remote and local--were one branch. Like in SVN. It is here where git pull --rebase comes into play. You no longer merge--you actually commit on top of the remote branch. That's what it actually is about.

Whether it's dangerous or not is the question of whether you are treating local and remote branch as one inseparable thing. Sometimes it's reasonable (when your changes are small, or if you're at the beginning of a robust development, when important changes are brought in by small commits). Sometimes it's not (when you'd normally create another branch, but you were too lazy to do that). But that's a different question.

这篇关于我应该什么时候使用git pull --rebase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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