Created
March 15, 2010 18:24
-
-
Save jamie/333137 to your computer and use it in GitHub Desktop.
git helper to track remote branches for existing local branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Sets up remote tracking if you forgot to --track a branch, | |
# or if you're setting up a new branch. | |
# Save in ~/bin/ or somewhere else on your path. | |
# Usage: | |
# git track [[remote] branch] | |
# remote defaults to 'origin' | |
# branch defaults to the name of the current local branch | |
# assumes the specified remote already exists. | |
ref = `git symbolic-ref HEAD`.chomp | |
branch = ARGV.pop || ref.split('/').last | |
remote = ARGV.pop || "origin" | |
`git config branch.#{branch}.remote #{remote}` | |
`git config branch.#{branch}.merge #{ref}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment