No Pugs

they're evil

Creating a remote branch using git

It’s common to need a new branch but the process in git has a few more steps than with most other SCMs.

The branch I will be creating will be called new_branch and I will create it in a remote repository named origin.

git push origin HEAD:new_branch

You can use the old branch’s name instead of HEAD if you’d like. Using HEAD just allows me to not have to know the current branch name.

git fetch origin
git checkout --track -b new_branch origin/new_branch

And there you have it, you’re now on new_branch which is tracking origin/new_branch

Published on 08/04/2011 at 09:06AM under .

Comment Creating a remote branch using git

Powered by Typo – Thème Frédéric de Villamil | Photo Glenn