Created
          December 8, 2015 19:06 
        
      - 
      
- 
        Save slucero/32e8c98478d87b555fe4 to your computer and use it in GitHub Desktop. 
Revisions
- 
        slucero created this gist Dec 8, 2015 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/usr/bin/env ruby ############################## # Create local tracking branches for all remote branches # that don't have local branches with a matching name. # # TODO: Add remote name as an agument # TODO: Add option for pass-through grep arguments to filter branches ############################## # TODO: Accept this as an argument REMOTE = 'origin' # Filter only branches not already existing locally local_branches = %x(git branch | sed 's/^*/ /' | sort).split remote_branches = %x(git branch -r | sed 's&#{REMOTE}/&&' | sort).split untracked_branches = remote_branches - local_branches # Create a tracking branch for each untracked branch untracked_branches.each { |branch| remote_branch = "#{REMOTE}/#{branch}" puts "Creating a tracking branch for #{branch}:#{remote_branch}" %x(git branch --track #{branch} #{remote_branch}) }