Skip to content

Instantly share code, notes, and snippets.

@andrewle
Created October 17, 2009 06:08
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 andrewle/212259 to your computer and use it in GitHub Desktop.
Save andrewle/212259 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
# A quick little ruby script to run in the shell to have your existing
# local branch track a remote branch
# Ex: git-track add origin master
# git-track remove origin master
if ARGV.empty? or ARGV.length < 3
puts "USAGE: git-track [add|remove] <remote-name> <branch-name>\n\n"
exit
end
`git sh-setup require_work_tree`
case ARGV[0]
when 'add'
`git config --add branch.#{ARGV[2]}.remote #{ARGV[1]}`
`git config --add branch.#{ARGV[2]}.merge refs/heads/#{ARGV[2]}`
when 'remove'
`git config --unset branch.#{ARGV[2]}.remote`
`git config --unset branch.#{ARGV[2]}.merge`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment