I use the following command to push to my remote branch:
git push origin sandbox
If I say
git push origin
does that push changes in my other branches too, or does it only update my current branch? I have three branches: master, production and sandbox.
The git push documentation is not very clear about this, so I’d like to clarify this for good.
Which branches and remotes do the following git push commands update exactly?
git push
git push origin
origin above is a remote.
I understand that git push [remote] [branch] will push only that branch to the remote.
You can control the default behavior by setting push.default in your git config. From the git-config(1) documentation:
Defines the action git push should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line. Possible values are:
nothing: do not push anythingmatching: (default before Git 2.0) push all matching branchesAll branches having the same name in both ends are considered to be matching.
upstream: push the current branch to its upstream branch (trackingis a deprecated synonym for upstream)current: push the current branch to a branch of the same namesimple: (new in Git 1.7.11, default since Git 2.0) like upstream, but refuses to push if the upstream branch’s name is different from the local oneThis is the safest option and is well-suited for beginners.
Command line examples:
To view the current configuration:
To set a new configuration: