Git remote tracking existing local branch

git

Wed Oct 13 10:45:27 -0700 2010

As of git 1.7.0...

Say you have checked out a new local branch on your project:

$ git checkout -b feature_x 

Made your code changes and committed to 'feature_x' branch. You would now like to keep a copy of this branch in your remote repository called 'origin':

$ git push origin feature_x

Now that you have remote branch 'origin/feature_x', you would like for the local branch 'feature_x' to be tracked to 'origin/feature_x':

$ git branch --set-upstream feature_x origin/feature_x

Now whenever on 'feature_x' branch, you do:

$ git push
$ git pull

You will be pushing to and pulling from remote 'origin/feature_x' branch.

blog comments powered by Disqus