Git: set up remote branch tracking post factum

I often have the following scenario:
– create local repository/branch
– create gitorious project/repository
– push branch to gitorious

This way you end up with your local branch not tracking the remote one. You know you’re not tracking when you have to specify the branch every time you push/pull and when you don’t see how much commits you are ahead of the remote. It is a matter of setting up the correct tracking configuration, something like this for the master branch:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

However, I just discovered that since git 1.7 there is now a command for this:

git branch --set-upstream master origin/master

much easier to remember!

2 thoughts on “Git: set up remote branch tracking post factum”

Leave a Reply

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