Last Updated: February 25, 2016
·
2.344K
· kindari

Push current branch only

When using tracking branches, You can push only the current branch you are on rather then all branches you have. This is a more sensible setting for me.

git config --global push.default tracking
git checkout -t origin/test
echo foo > test && git commit -am "Test"
git push # pushes test to origin/test

If you have an existing branch with no upstream set, push once like this:

git push -u origin branch

This becomes especially useful when you have different branch names locally and remotely. In my company, our branch names are like:

group/username/topic

Locally, I just use topic as my branch. Without this setting, my push command every time would be:

git push origin topic:group/username/topic