现象:可以git pull下来,然后再git status,显示正常。
通过浏览器访问git地址,发现没有别人提交的修改,最新修改是自己提交的。
咨询同事,给出一个命令,就搞定可以正常push了。
git config --global push.default current
于是切换checkout到其他分支,逐个执行git status命令,返回结果都是正常的:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded
那么这个push.default到底是个什么东东,git help push 找到下面的解释。
push.default
Defines the action git push should take if no refspec is explicitly given. Different values are well-suited for specific workflows; for instance, in a purely central workflow (i.e. the fetch source is equal to the push destination), upstream is probably what you want. Possible values are:
nothing - do not push anything (error out) unless a refspec is explicitly given. This is primarily meant for people who want to avoid mistakes by always being explicit.
current - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.
upstream - push the current branch back to the branch whose changes are usually integrated into the current branch (which is called @{upstream}). This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow).
simple - in centralized workflow, work like upstream with an added safety to refuse to push if the upstream branch’s name is different from the local one.
When pushing to a remote that is different from the remote you normally pull from, work as current. This is the safest option and is suited for beginners.
This mode has become the default in Git 2.0.
matching - push all branches having the same name on both ends. This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push to will have these two branches, and your local maint and master will be pushed there).
To use this mode effectively, you have to make sure all the branches you would push out are ready to be pushed out before running git push, as the whole point of this mode is to allow you to push all of the branches in one go. If you usually finish work on only one branch and push out the result, while other branches are unfinished, this mode is not for you. Also this mode is not suitable for pushing into a shared central repository, as other people may add new branches there, or update the tip of existing branches outside your control.
This used to be the default, but not since Git 2.0 (simple is the new default).
猜测原来的push模式是 matching,也就是每一次push 所有的分支到远程rep。
原来的设置已经被改成current,那如果再来一次的话,怎么查看自己系统的push模式呢?
shuohai@SHUOHAI-NOTE /e/dzk/GeocodingService (master)
$ git config --get push.default
current
shuohai@SHUOHAI-NOTE /e/dzk/GeocodingService (master)
$ git config
usage: git config [options]
Config file location
--global use global config file
--system use system config file
--local use repository config file
-f, --file use given config file
--blob read config from given blob object
Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--get-urlmatch get value specific for the URL: section[.var] URL
--replace-all replace all matching variables: name value [value_regex]
--add add a new variable: name value
--unset remove a variable: name [value-regex]
--unset-all remove all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit open an editor
--get-color find the color configured: [default]
--get-colorbool
find the color setting: [stdout-is-tty]
Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)
Other
-z, --null terminate values with NUL byte
--includes respect include directives on lookup
1 http://www.binkery.com/archives/381.html
2 http://www.360doc.com/content/14/0213/16/10058718_352227358.shtml