Jim Kubicek

Octo-Impressive

Configure Git to Only Push Current Branch

I’ve always used plain git push to update my remote repos and I’m finally getting tired of seeing this error every time:

(master)> git push
...
To git@github.com:jkubicek/my_proj.git
   21b430d..dd378ca  master -> master
 ! [rejected]        release -> release (non-fast-forward)
error: failed to push some refs to 'git@github.com:jkubicek/my_proj.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. 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.

I can only blame this on my utter laziness, because the answer is right in the error text. Run the following command to configure git push to only push your current branch.

git config --global push.default current

I should have done this months ago.

Comments