Git: How to set a default push remote repo

How to configure a default remote branch to push to when doing `git push`. Current versions of git throw a warning whenever you try to push to a remote repository without specifying a matching branch name. This can be quite annoying if the remote branches have long names.

Normally you would do

git push [origin] [branchname]

For a while, I didn’t mind this but I’ve gotten to the point where I’d rather not have to type out branch names. The fix is to tell git to push to the origin repo and the remote branch that has the same name as the branch you’re currently on.

To do this, add the following setting to git by typing this in the terminal:

git config --global push.default current
 

Vuyisile

 

Leave a Reply

%d bloggers like this: