How to only git push to Remote Upstream Branch?

Sometimes it gets tedious to push only one branch to the upstream server by typing the full command into the command line git push origin the-remote-branch. And the worst part is that it is error prone, especially if you get the casing wrong.

Instead, wouldn’t it be nice that all you need to do is type git push? Just run the following command to set this configuration.

$ git config --global push.default upstream

If you run into a problem with regards to “an invalid refspec” whilst you are on your master branch, execute the following command so that you are able to realign the refspec for the master branch in your repository.

git config remote.origin.push HEAD
blog comments powered by Disqus