Git Warning push.default is unset

git 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

When push.default is set to 'matching', 	
git will push local branches to the remote branches 
that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple' behavior, 	
which only pushes the current branch to the corresponding remote branch 
that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. 
Use the similar mode 'current' instead of 'simple' 
if you sometimes use older versions of Git)

事实上这并不会影响你push的结果,最终push还会成功,因为这只是一个”warning“。会在后面看到push成功的结果。

Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.10 KiB | 0 bytes/s, done.
Total 10 (delta 9), reused 0 (delta 0)

你可以按照他说的那样运行: $ git config –global push.default matching

或者

$ git config --global push.default simple

命令,以后再push就不会有警告了。

下面说一下 push.default matchingpush.default simple 的区别:

  • push.default设置maching的意思是:git push 会把你本地所有分支push到名称相对应的远程主机上。这意味着可能你会在不经意间push一些你原本没打算push的分支。

  • push.default设置成simple的意思是:git push仅仅把当前所在分支push到从当初git pull pull下来的那个对应分支上,另外,这个过程也会同时检查各个分支的名称是否相对应。

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy