Thursday, August 19, 2010

git: Pushing a new branch back to an origin

OK, I know this is straight forward git stuff, but I just couldn't find a clear example anywhere. I cloned a remote git repository, created a new local branch and then wanted to push that branch back to the original remote repository (without merging it first).

First, I cloned a remote repository, e.g.:

git clone git@github.com:von/sandbox.git

Then I created a new branch locally and make changes in that branch:

cd sandbox

git checkout -b new-branch

edit && commit

Now I pushed the new branch back to the remote repository (i.e. origin) without merging it into the main branch (i.e. master). To do this, while on new-branch, just do a git push origin HEAD, i.e.:

git checkout new-branch

git push origin HEAD

Basically you are saying push to origin the current HEAD.

No comments:

Post a Comment