Setting a default git remote

This bit me again today, so I thought I’d look it up and write it down here so I can find it.

When you create a git repository using git clone, git very helpfully sets up a default remote repository and branch for you, pointing back at the originating repository. This is helpful, because it means you can use the short forms of git fetch, git pull, and git push.

When you create a repository from scratch, as I have done a few times for this project, you don’t get this handy help, which means having to use the full version of these commands, for example git push origin master.

The trick is to use git branch --set-upstream master origin/master Once you have done this, any push while you are on the “master” branch will go to the master branch of the remote named “origin”.

Simples.

No related content found.

Leave a Reply

Your email address will not be published. Required fields are marked *