Friday, July 24, 2009

How To Branch Against a Remote Server in GIT

Here Are Better Instructions for GIT for Branching Locally Then Remotely
(instructions are really here, but I didn't even notice the first time around)

git checkout -b waiting-for-comments # make the branch locally
git push origin waiting-for-comments
git checkout master
git branch -f waiting-for-comments origin/waiting-for-comments
git checkout waiting-for-comments



The instructions are long and annoying because GIT will not set up tracking correctly otherwise

(based on this http://www.zorched.net/2008/04/14/start-a-new-branch-on-your-remote-git-repository/)

git checkout -b waiting-for-comments # make the branch locally
git push origin HEAD # will make the branch in the remote server, though there are other ways to do this
git checkout master # switch to the branch you are really working on
git branch -d waiting-for-comments # delete the branch locally, otherwise we are not "tracking" the right branch
git fetch origin # update from the remote server, so we're seeing the branches correctly
git branch -r # get the branch names from the remote server
git checkout --track -b waiting-for-comments origin/waiting-for-comments # checkout correctly

version with no comments

git checkout -b waiting-for-comments
git push origin HEAD
git checkout master
git branch -d waiting-for-comments
git fetch origin
git branch -r
git checkout --track -b waiting-for-comments origin/waiting-for-comments

Then you could make a .sh, of course, using variables and that.

No comments: