git_remote_branch is a simple command-line tool that makes it very easy to manipulate branches published in shared repositories.
It achieves this goal by sticking to a few principles:
keep grb's commands extremely regular (they all look alike)
support aliases for commands
print all commands it runs on your behalf in red, so you eventually learn them
Another nice thing about git_remote_branch is that it can simply explain a command (print out all the corresponding git commands) instead of running them on your behalf.
Note: git_remote_branch assumes that the local and remote branches have the same name. Multiple remote repositories (or origins) are supported.
gem install git_remote_branch
If you're on Windows, you can optionally install the following gems, to get color output:
gem install windows-pr win32console
parts between brackets are optional
When 'origin_server' is not specified, the name 'origin' is assumed.
Available commands (with aliases):
$ grb [-h|help] #=> Displays help
create (alias: new)
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 create branch_name [origin_server]
publish (aliases: remotize, share)
Publish an existing local branch to the remote server. Set up the local branch to track the new remote branch.
$ grb publish branch_name [origin_server]
delete (aliases: destroy, kill, remove, rm)
Delete the remote branch then delete the local branch. The local branch is not deleted if there are pending changes.
$ grb delete branch_name [origin_server]
track (aliases: follow grab fetch)
Track an existing remote branch locally and checkout the branch.
$ grb track branch_name [origin_server]
rename (aliases: rn mv move)
Rename a remote branch and its local tracking branch. The branch you want to rename must be checked out.
# On branch to be renamed
All commands can be prepended by the word 'explain'. Instead of executing the command, git_remote_branch will simply output the list of commands you need to run to accomplish that goal. Examples:
$ 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
Explain your specific case:
$ grb explain create my_branch github git_remote_branch version 0.3.0 List of operations to do to create a new remote branch and track it locally: git push github master:refs/heads/my_branch git fetch github git branch --track my_branch github/my_branch git checkout my_branch
This, of course, works for each of the grb commands.
More on git_remote_branch
git_remote_branch in its current form was inspired by a script created by Carl Mercier and made public on his blog: No nonsense GIT, part 1: git-remote-branch
Mathieu Martin email@example.com
Caio Chassot firstname.lastname@example.org
Carl Mercier github.com/cmer
git_remote_branch is licensed under the MIT License. See the file LICENSE for details.
This version of git_remote_branch has been tested with
OS X Lion
past versions were known to work on Linux and Windows
Ruby 1.8.7, 1.9.2, 1.9.3
Let me know if you encounter problems running git_remote_branch with your platform.