The question is what are you pushing, and to where:
current
:
- "what" is only your current branch (no other branches),
- "to where" is a branch of the same name (created if it doesn't exist) in the upstream repo.
upstream
:
- "what" is also only the current branch,
- "to where" is to whatever branch (not necessarily of the same name) on the upstream repo has been assigned as an upstream branch for the local branch you are pushing.
As explained here, Git2.0 will additionally introduce a new default for push.default
: simple
simple
is like upstream
, but the upstream has to have the same name as well or the push will fail.
Pushing only one branch (with the mode "simple
", "current
" or "upstream
") avoids the scenario where all matching branches are pushed (mode "matching
", which was the default for a long time), even though some of your branches might not be ready to be pushed.
(master)> git push
...
To [email protected]:jkubicek/my_proj.git
21b430d..dd378ca master -> master
! [rejected] release -> release (non-fast-forward)
error: failed to push some refs to '[email protected]:jkubicek/my_proj.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart.
hint: If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch.
The difference between the two (current
and upstream
) is in the pull (what to pull from the remote to your branch?):
pushing "current
" doesn't mean that your current branch B
has remote/B
has its upstream branch.
Ie: branch.B.merge
isn't set, when your are pushing the "current
" branch.
Ie: when pulling to B
, git won't know what branch to pull.
pushing "upstream
" means that your current branch B
has remote/B
has its upstream branch.
Ie: branch.B.merge
is set, when your are pushing the "upstream
" branch.
Ie: when pulling to B
, git knows what branch to pull (as well as which remote repo: branch.B.remote
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…