LearnGit Pro Tip: Let grb Handle Remote Branches for You


writes on February 10, 2011

It seems like git has been picking up more and more traction in the web community, and tools like Tower and gitx seem to be making git tons more accessible to designers. One of my favorite features of git is how easy it makes branching. Most of the time that I work on a new feature I create a branch for it in my git repo, and I typically push that branch up to the server if it’s going to be around for more than a few hours. The commands for doing all of that can be hard to remember, though. Enter grb, short for git_remote_branch.

grb is a command line tool that makes creating remote branches both locally and on the server really easy. For example, to create a remote branch you’d typically have to create the new remote branch, fetch, make sure that no remote branch with the name you’d like to use already exists, create a new tracking branch, and then check out the new tracking branch. That looks something like:

> git push origin master:refs/heads/new_branch
> git fetch origin
> git branch --track testing origin/new_branch
> git checkout testing

But with grb this is as easy as:

> grb new new_branch

To remove a remote branch just run:

> grb rm new_branch

grb includes features for creating, removing, and renaming remote branches, as well as for pulling and tracking remote branches. It’s a tool I’ve been using for over a year now, and has been invaluable in my toolkit. It’s a piece of cake to install, too. Just make sure you have Ruby available and run:

> gem install git_remote_branch

On any modern Mac Ruby came preinstalled and on Windows it’s easy to install Ruby with the Ruby Windows Installer. You’ll want the gem command around anyway because tons of web projects like SASS are delivering their tools through RubyGems.

What tools are you using to help out with your version control workflow?


Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you've been dreaming about.

Get Started

2 Responses to “Git Pro Tip: Let grb Handle Remote Branches for You”

  1. If you’re using any recent version of git, there are much simpler ways of creating remote branches:

    git checkout -b mynewbranch # creates and checks out a new branch locally
    git push origin mynewbranch # pushes the new branch to your remote

    To remove the branch from remote:
    git push origin :mynewbranch

    I highly recommend http://cheat.errtheblog.com/s/git as a git resource.

  2. I use the git bundle in Textmate. Ctrl+g is a lot faster for me than typing, and it handles most of the primary functions (including branching). This is a good tip though.

Leave a Reply

You must be logged in to post a comment.

man working on his laptop

Are you ready to start learning?

Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you've been dreaming about.

Start a Free Trial
woman working on her laptop