Skip to Content Collective Idea Home

HOW TO: Setup a new local & remote Git Branch

by Daniel Morrison

A question came up in the office today:

What’s the best way to create a new tracking branch both locally and on the server?

Steve decided this 2-liner was best:

git checkout -b newBranch
git push -u origin newBranch

Have a better way? Let us know!

Comments

John Nunemaker
::

I love the git_remote_branch gem.

grb create and you are done.


Stefan
::

If you set branch.autosetupmerge = true you can avoid the -u I think. But you still need the two commands.

Deleting a remote branch is kinda clunky using pure git. grb makes sense there (even though I don’t use it).