Skip to content

Instantly share code, notes, and snippets.

@stve
Forked from jamie/git-track
Created June 16, 2010 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stve/440184 to your computer and use it in GitHub Desktop.
Save stve/440184 to your computer and use it in GitHub Desktop.
#!/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