混帐配置 : "remote.origin.push" vs "push.default"

标签 git

如何执行以下命令:

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 origingit 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 --getgit config --get-allgit config --get-regexp ], --local等等,选项限制 git 从哪里读取,如果没有一个,它会从 所有 中读取,如果在不止一个地方设置了某些东西,“最本地”会覆盖“不太本地”。 )

关于混帐配置 : "remote.origin.push" vs "push.default",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19504544/

相关文章:

regex - 获取 Windows 上 Git Hook 的 %AppData% 路径(或其他环境变量)(10)

checkout 、 pull 、 checkout 、 merge/ rebase 的 Git 快捷方式

git - 我需要做什么来克隆 github repo

git - 重新设置分支以掌握恢复

git - 当子模块是私有(private) Github repos 时 git 子模块的问题

git - Git 中的供应商分支

GIT checkout 除了一个文件夹

git:如何 "consolidate"本地提交

python - 是否有纯 Python 中的 Git 实现?

git - 使用 GitHub API 创建文件夹