警告:push.default 未设置;它的隐含值在 Git 2.0 中发生了变化
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13148066/
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
Warning: push.default is unset; its implicit value is changing in Git 2.0
提问by Marko
I've been using Git for a while now and have recently downloaded an update only to find this warning message come up when I try to push
.
我已经使用 Git 一段时间了,最近下载了一个更新,却发现当我尝试push
.
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
I can obviously set it to one of the values mentioned, but what do they mean? What's the difference between simple
and matching
?
我显然可以将它设置为提到的值之一,但它们是什么意思?simple
和 和有matching
什么区别?
If I change it on one client will I need to do anything on other clients that I share repos with?
如果我在一个客户端上更改它,我是否需要对与我共享 repos 的其他客户端执行任何操作?
回答by hammar
It's explained in great detail in the docs, but I'll try to summarize:
文档中对此进行了非常详细的解释,但我会尝试总结一下:
matching
meansgit push
will push all your local branchesto the ones with the same name on the remote. This makes it easy to accidentally push a branch you didn't intend to.simple
meansgit push
will push only the current branch to the one thatgit pull
would pull from, and also checks that their names match. This is a more intuitive behavior, which is why the default is getting changed to this.
matching
意味着git push
会将您所有的本地分支推送到远程上具有相同名称的分支。这很容易意外地推送您不打算推送的分支。simple
意味着git push
将仅将当前分支推送到git pull
将从 中拉出的分支,并检查它们的名称是否匹配。这是一种更直观的行为,这就是为什么将默认值更改为此的原因。
This setting only affects the behavior of your local client, and can be overridden by explicitly specifying which branches you want to push on the command line. Other clients can have different settings, it only affects what happens when you don't specify which branches you want to push.
此设置仅影响本地客户端的行为,并且可以通过在命令行上显式指定要推送的分支来覆盖。其他客户端可以有不同的设置,它只会影响当您没有指定要推送的分支时会发生什么。
回答by wgp
I realize this is an old post but as I just ran into the same issue and had trouble finding the answer I thought I'd add a bit.
我意识到这是一篇旧帖子,但因为我刚刚遇到了同样的问题并且无法找到答案,所以我想我会补充一点。
So @hammar's answer is correct. Using push.default simple
is, in a way, like configuring tracking on your branches so you don't need to specify remotes and branches when pushing and pulling. The matching
option will push all branches to their corresponding counterparts on the default remote (which is the first one that was set up unless you've configured your repo otherwise).
所以@hammar 的回答是正确的。使用push.default simple
is,在某种程度上,就像在你的分支上配置跟踪,这样你就不需要在推和拉时指定遥控器和分支。该matching
选项会将所有分支推送到默认远程上的相应分支(这是第一个设置的分支,除非您以其他方式配置了存储库)。
One thing I hope others find useful in the future is that I was running Git 1.8 on OS X Mountain Lion and never saw this error. Upgrading to Mavericks is what suddenly made it show up (running git --version
will show git version 1.8.3.4 (Apple Git-47)
which I'd never seen until the update to the OS.
我希望其他人将来会发现有用的一件事是,我在 OS X Mountain Lion 上运行 Git 1.8 并且从未见过此错误。升级到 Mavericks 是它突然出现的原因(运行git --version
将显示git version 1.8.3.4 (Apple Git-47)
在更新到操作系统之前我从未见过的内容。
回答by Tom Barron
If you get a message from git complaining about the value simple
in the configuration, check your git version
.
如果您从 git 收到一条消息,抱怨simple
配置中的值,请检查您的git version
.
After upgrading XCode
(on a Mac
running Mountain Lion
), which also upgraded git
from 1.7.4.4to 1.8.3.4, shells started before the upgrade were still running git 1.7.4.4and complained about the value simple
for push.default in the global config.
升级后XCode
(在Mac
运行时Mountain Lion
),也git
从1.7.4.4升级到1.8.3.4,升级前启动的 shell 仍在运行 git 1.7.4.4并抱怨simple
全局配置中 push.default的值。
The solution was to close the shells running the old version of git
and use the new version!
解决方案是关闭运行旧版本的shellgit
并使用新版本!
回答by Eugene Yarmash
I was wondering why I was getting that big warning message on Ubuntu 16.04 (which comes with Git 2.7.4), but not on Arch Linux. The reason is that the warning was removed in Git 2.8(March 2016):
我想知道为什么我会在 Ubuntu 16.04(Git 2.7.4 附带)上收到这么大的警告消息,而在 Arch Linux 上却没有。原因是在Git 2.8(2016 年 3 月)中删除了警告:
Across the transition at around Git version 2.0, the user used to get a pretty loud warning when running "git push" without setting push.default configuration variable. We no longer warn because the transition was completed a long time ago.
在 Git 2.0 版左右的过渡期间,用户过去常常在运行“git push”而不设置 push.default 配置变量时收到非常响亮的警告。我们不再发出警告,因为转换很久以前就完成了。
So you won't see the warning if you have Git 2.8 and later and don't need to set push.default
unless you want to change the default 'simple'
behavior.
因此,如果您有 Git 2.8 及更高版本,则不会看到警告,push.default
除非您想更改默认'simple'
行为,否则不需要设置。