Skip to content

Instantly share code, notes, and snippets.

@takaaki
Created October 17, 2009 16:34
Show Gist options
  • Save takaaki/212396 to your computer and use it in GitHub Desktop.
Save takaaki/212396 to your computer and use it in GitHub Desktop.

#grb git-remote-branch

Usage: grb create branch_name [origin_server]
grb publish branch_name [origin_server]
grb rename branch_name [origin_server]
grb delete branch_name [origin_server]
grb track branch_name [origin_server]

Notes:

  • If origin_server is not specified, the name 'origin' is assumed (git's default)
  • The rename functionality renames the current branch

The explain meta-command: you can also prepend any command with the keyword 'explain'. Instead of executing the command, git_remote_branch will simply output the list of commands you need to run to accomplish that goal. Example: grb explain create grb explain create my_branch github

All commands also have aliases: create: create, new delete: delete, destroy, kill, remove, rm publish: publish, remotize, share rename: rename, rn, mv, move track: track, follow, grab, fetch

##create

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

##publish

List of operations to do to publish an exiting local branch:

git push origin branch_to_publish:refs/heads/branch_to_publish
git fetch origin
git config branch.branch_to_publish.remote origin
git config branch.branch_to_publish.merge refs/heads/branch_to_publish
git checkout branch_to_publish

##rename

List of operations to do to rename a remote branch and its local tracking branch:

git push origin master:refs/heads/branch_to_rename
git fetch origin
git branch --track branch_to_rename origin/branch_to_rename
git checkout branch_to_rename
git push origin :refs/heads/master
git branch -d master

##delete

List of operations to do to delete a local and a remote branch:

git push origin :refs/heads/branch_to_delete
git branch -d branch_to_delete

##track

List of operations to do to track an existing remote branch:

git fetch origin
git branch --track branch_to_track origin/branch_to_track
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment