警告:push.default未设置;它的隐含值在Git 2.0中发生了变化

本文翻译自:Warning: push.default is unset; its implicit value is changing in Git 2.0

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 ? simplematching之间有什么区别?

If I change it on one client will I need to do anything on other clients that I share repos with? 如果我在一个客户端上更改它,我是否需要在我共享回购的其他客户端上做任何事情?


#1楼

参考:https://stackoom.com/question/tAPa/警告-push-default未设置-它的隐含值在Git-中发生了变化


#2楼

It's explained in great detail in the docs , but I'll try to summarize: 它在文档中有详细解释,但我会总结一下:

  • matching means git push will push all your local branches to the ones with the same name on the remote. matching意味着git push会将所有本地分支推送到远程上具有相同名称的分支 This makes it easy to accidentally push a branch you didn't intend to. 这样很容易意外地推动您不想要的分支。

  • simple means git push will push only the current branch to the one that git pull would pull from , and also checks that their names match. simple意思是git push只将当前分支推送到git pull将从中拉出的分支 ,并检查它们的名称是否匹配。 This is a more intuitive behavior, which is why the default is getting changed to this. 这是一种更直观的行为,这就是默认情况发生变化的原因。

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 . 其他客户端可以具有不同的设置, 它只会影响您未指定要推送哪些分支时发生的情况


#3楼

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. 所以@ hammar的回答是正确的。 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. 在某种程度上,使用push.default simple就像在分支上配置跟踪一样,因此在推拉时不需要指定遥控器和分支。 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). matching选项会将所有分支推送到默认远程控制器上的相应对应部分(这是第一个设置的部分,除非您已配置了您的存储库)。

扫描二维码关注公众号,回复: 10412002 查看本文章

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. 我希望其他人在将来发现有用的一件事是我在OS X Mountain Lion上运行Git 1.8并且从未看到过这个错误。 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. 升级到Mavericks是突然出现的(运行git --version将显示git version 1.8.3.4 (Apple Git-47) ,这是我在操作系统更新之前从未见过的。


#4楼

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.4 to 1.8.3.4 , shells started before the upgrade were still running git 1.7.4.4 and complained about the value simple for push.default in the global config. 在升级XCode (在运行Mountain LionMac上)之后,还将git1.7.4.4升级到1.8.3.4 ,在升级之前启动的shell仍在运行git 1.7.4.4并抱怨全球push.default的价值simple配置。

The solution was to close the shells running the old version of git and use the new version! 解决方案是关闭运行旧版本git的shell并使用新版本!


#5楼

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. 我想知道为什么我在Ubuntu 16.04(Git 2.7.4附带)上收到了那个大警告信息,但是在Arch Linux上没有。 The reason is that the warning was removed in Git 2.8 (March 2016): 原因是在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. 在Git 2.0版本的转换过程中,用户在运行“git push”时发出了非常大的警告而没有设置push.default配置变量。 We no longer warn because the transition was completed a long time ago. 我们不再警告,因为过渡很久以前就完成了。

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'行为。

发布了0 篇原创文章 · 获赞 7 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/asdfgh0077/article/details/105201395