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
autosetuprebase vs autosetupmerge
提问by Rob Wilkerson
I was just knocking around in my global .gitconfig
file 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 autosetupmerge
and 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:
这里违反直觉的是这些首选项的命名。它们看起来确实是指相同的功能,但实际上它们不是:
autosetupmerge
controls whethergit branch
andgit checkout -b
imply the--track
option, i.e. with your setting ofalways
,git checkout branchname
, ifbranchname
exists on a remote but not locally, will createbranchname
tracking its remote counterpartgit checkout -b newbranch
will create a new branchnewbranch
tracking whichever branch you had checked out before issuing this command
autosetuprebase
controls whether new branches should be set up to be rebased upongit pull
, i.e. your setting ofalways
will result in branches being set up such thatgit pull
always performs a rebase, not a merge. (Be aware that existing branches retain their configuration when you change this option.)
autosetupmerge
控制是否git branch
和git checkout -b
暗示--track
选项,即与您的设置always
,git checkout branchname
,如果branchname
存在于远程但不在本地,将创建branchname
跟踪其远程对应物git checkout -b newbranch
将创建一个新分支,newbranch
跟踪您在发出此命令之前签出的任何分支
autosetuprebase
控制是否应将新分支设置为 rebasegit pull
,即您的设置always
将导致分支设置为git pull
始终执行 rebase,而不是合并。(请注意,更改此选项时,现有分支会保留其配置。)
So it makes perfect sense to have both autosetupmerge = always
and 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
回答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 branch
or git checkout
that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch..rebase").
当一个新分支与另一个分支一起创建git branch
或git 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。
回答by Bruce Stephens
You probably don't need to set up autosetupmerge---the default is true.
您可能不需要设置 autosetupmerge ---默认值为 true。