如何执行以下命令:
git config remote.origin.push refs/heads/master:refs/heads/master
与以下命令相关:
git config push.default <option>
(使用 --local
或 --global
选项)
哪里<option>
是其中之一:
nothing
matching
upstream (formerly tracking)
current
simple
?
我想我理解第二个配置命令,但我不明白第一个命令与第二个命令的条件/关系。以下是一些提供此问题背后背景的引用资料:
最佳答案
当你运行时:
git push origin ...
remote.origin.push
中的任何设置覆盖 push.default
中设置的任何内容.更一般地,如果 remote.<em>name</em>.push
未设置(这里 name
是 origin
),git 返回到 push.default
,然后如果也没有设置,它将返回到链接中描述的内置默认值。
(编辑:如 Breaking Benjamin's comment below 和我对此的回复所述,如果 包含至少一个 refspec 的 ...
部分,则 refspec 覆盖remote.origin.push
。因此,remote.origin.push
仅在您在命令行上显式或隐式命名 origin
时适用, 也省略命令行上的任何和所有 refspecs。例如,git push
与no arguments that discovers origin
或 git push origin
没有其他参数,Git 会查找您的 remote.origin.push
设置并使用它;但是 git push origin xyz
不使用您的 remote.origin.push
设置。当然,上面的 ...
部分可以包含更多标志,因此此时正确的问题是 ...
部分是否包含任何 refspecs。)
注意:
git config --local na.me value
和没有--local
的意思是一样的.当设置值(如此处)时 --local
, --global
, 和 --file <em>filename</em>
选项控制值的设置位置,但是 --local
是默认值。
(取值时:
git config na.me
[或git config --get
或 git config --get-all
或 git config --get-regexp
], --local
等等,选项限制 git 从哪里读取,如果没有一个,它会从 所有 中读取,如果在不止一个地方设置了某些东西,“最本地”会覆盖“不太本地”。 )
关于混帐配置 : "remote.origin.push" vs "push.default",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19504544/