git autosetuprebase 与 autosetupmerge

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5480069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:28:19  来源:igfitidea点击:

autosetuprebase vs autosetupmerge

git

提问by Rob Wilkerson

I was just knocking around in my global .gitconfigfile and I noticed that I've managed to end up with this:

我只是在我的全局.gitconfig文件中敲了一下,我注意到我已经设法结束了这个:

[branch]
  autosetupmerge = always
  autosetuprebase = always

That seemed more than a little counterintuitive, but after doing some reading, I still have no idea whether I need both or whether it's sufficient to remove autosetupmergeand just retain autosetuprebase. Most projects that I'm working have a straight downstream->upstream flow, so rebasing is generally preferred when dealing with branches.

这似乎有点违反直觉,但是在阅读了一些内容之后,我仍然不知道我是否需要两者,或者是否足以删除autosetupmerge和只保留autosetuprebase. 我正在工作的大多数项目都有一个直接的下游-> 上游流程,因此在处理分支时通常首选 rebase。

回答by laszlok

What is counterintuitive here is the naming of these preferences. They do look like they refer to the same functionality, but in fact they don't:

这里违反直觉的是这些首选项的命名。它们看起来确实是指相同的功能,但实际上它们不是:

  • autosetupmergecontrols whether git branchand git checkout -bimply the --trackoption, i.e. with your setting of always,
    • git checkout branchname, if branchnameexists on a remote but not locally, will create branchnametracking its remote counterpart
    • git checkout -b newbranchwill create a new branch newbranchtracking whichever branch you had checked out before issuing this command
  • autosetuprebasecontrols whether new branches should be set up to be rebased upon git pull, i.e. your setting of alwayswill result in branches being set up such that git pullalways performs a rebase, not a merge. (Be aware that existing branches retain their configuration when you change this option.)
  • autosetupmerge控制是否git branchgit checkout -b暗示--track选项,即与您的设置always
    • git checkout branchname,如果branchname存在于远程但不在本地,将创建branchname跟踪其远程对应物
    • git checkout -b newbranch将创建一个新分支,newbranch跟踪您在发出此命令之前签出的任何分支
  • autosetuprebase控制是否应将新分支设置为 rebase git pull,即您的设置always将导致分支设置为git pull始终执行 rebase,而不是合并。(请注意,更改此选项时,现有分支会保留其配置。)

So it makes perfect sense to have both autosetupmerge = alwaysand autosetuprebase = always; in fact, that's also what I have.

因此,同时拥有autosetupmerge = always和是完全合理的autosetuprebase = always;事实上,这也是我所拥有的。

回答by guettli

since this is the first hit, if you search for "autosetuprebase" with google, here an advice:

由于这是第一次命中,如果您使用谷歌搜索“autosetuprebase”,这里有一个建议:

git config --global branch.autosetuprebase always

Source http://mislav.uniqpath.com/2010/07/git-tips/

来源http://mislav.uniqpath.com/2010/07/git-tips/

回答by RyanK

It's probably worth mentioning that there is a difference between autosetupmerge=always (in your config) and autosetupmerge=true (the default).

可能值得一提的是, autosetupmerge=always (在您的配置中)和 autosetupmerge=true (默认值)之间存在差异。

true will only setup merging for remote branches. always will include local branches as well.

true 只会为远程分支设置合并。总是也会包括当地分支机构。

You probably want true.

你可能想要真的。

回答by Viacheslav Kondratiuk

As I was looking for other possible options of "autosetuprebase" and it took some time to find them, here they are:

当我正在寻找“autosetuprebase”的其他可能选项时,花了一些时间才找到它们,它们是:

branch.autosetuprebase

When a new branch is created with git branchor git checkoutthat tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch..rebase").

当一个新分支与另一个分支一起创建git branchgit checkout跟踪另一个分支时,这个变量告诉 Git 设置 pull 到 rebase 而不是合并(请参阅“branch..rebase”)。

  • When never, rebase is never automatically set to true.
  • When local, rebase is set to true for tracked branches of other local branches.
  • When remote, rebase is set to true for tracked branches of remote-tracking branches.
  • When always, rebase will be set to true for all tracking branches.
  • 当 时never,rebase 永远不会自动设置为 true。
  • 当 时local,对于其他本地分支的跟踪分支,将 rebase 设置为 true。
  • 当 时remote,对于远程跟踪分支的跟踪分支,将 rebase 设置为 true。
  • 当 时always,所有跟踪分支的 rebase 将设置为 true。

Source: http://git-scm.com/docs/git-config.html

来源:http: //git-scm.com/docs/git-config.html

回答by Bruce Stephens

You probably don't need to set up autosetupmerge---the default is true.

您可能不需要设置 autosetupmerge ---默认值为 true。