git push时一堆警告的问题 : git config --global push.default matching 来解决.

访问量: 483

我们在 $ git push的时候,  就等同于:   $ git push origin <branch 名字>, 

99%的时候, $ git push 等同于  

$ git push origin master

等同于:

$ git push origin mater:master   (把本地的master分支推送到远程) 

对于很多同学, 会遇到这样的错误: 

siwei@siwei-linux:/workspace/zhi_dao_yuan_manage$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, 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)

大家要仔细读英文,它的意思就是: Git 对于 $ git push这个命令, 有两个策略:  

1. 把本地的当前分支的代码, 推送到远程的同名分支.   ( push.default = matching )

2. 把本地的当前分支的代码, 推送到 之前pull 过来的分支.    (  push.default = simple) 

所以, 我们要选择第一个. 也就是说, 简单的运行下这个命令即可: 


git config --global push.default matching

订阅/RSS Feed

Subscribe

分类/category