Our team uses git remote branches often to test concepts and for deployment version tracking. This allows us to avoid sending patches and cluttering up our master branch. Managing and tracking remote branches under git is a little ambiguous, especially for people who do not work with them often. While I do think it is a good idea to actually understand how to manage git remote branches directly through git, I also think the git_remote_branch gem makes life easier.
Sample Usage:
$ grb create branch_name
This will create a new local branch as well as a corresponding remote branch based on the branch you currently have checked out. Track the new remote branch. Checkout the new branch.
$ grb publish branch_name
This will publish an existing local branch to the remote server. Set up the local branch to track the new remote branch.
$ grb track branch_name
This will track an existing remote branch locally and checkout the branch.
There is also 'rename' and 'delete'. These commands above assume you are using the default remote server name of 'origin'. If not, you can append the remote name to them (see readme).
If you want to verify what git operations will be done, use 'explain'
$ grb explain create
git_remote_branch version 0.3.0
List of operations to do to create a new remote branch and track it locally:
git push origin master:refs/heads/branch_to_create
git fetch origin
git branch --track branch_to_create origin/branch_to_create
git checkout branch_to_create
Git 'r' done!
image source

Comments
Interesting post? Show some love and post a comment!Using pieces of this code? Post a link!
Add a Comment