Category Archives: SCM

Git New Remote Branch Cheatsheet

I seem to do this everyday on the job when I am coding and then forget on those weeks that I don’t code. Here’s the quickest way to create a remote branch that is tracked locally and remotely.

1
2
git checkout -b new_branch_name
git push -u origin new_branch_name

No fiddling around with git branch creation and checkout, then –set-upstream, All done in those 2 commands. The first command creates a new branch and sets that as your working tree. The second command pushes the current branch upstream to origin and at the same time handles –set-upstream to the given location. Neat? :)

While we’re at it, here’s how to delete it if you don’t need it anymore.

1
2
git push origin :new_branch_name
git branch -d new_branch_name

Branch all gone both locally and on the remote repository.

You can read this link if you are unfamiliar with git branching:

http://www.gitguys.com/topics/adding-and-removing-remote-branches/