Sha256: 14acf94b185a6d7226e0491033e2b17f098333776533ff3c70db3c21300995f0
Contents?: true
Size: 709 Bytes
Versions: 29
Compression:
Stored size: 709 Bytes
Contents
#!/usr/bin/env ruby # detect current branch current_branch = (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').scan(/^\* (.+)$/).flatten.first # use branch passed via command line or current branch if none was given branch = ARGV[0] || current_branch || raise("Need the branch name as first argument since the current branch could not be detected automatically") # switch the branch if it is not the current branch if branch != current_branch `git status`.include?('working directory clean') or raise 'Dirty working directory. Nothing was pushed.' `git checkout #{branch}` end # push branch to remote and track it `git push -u origin #{branch}` puts "#{branch} is now tracking origin/#{branch}"
Version data entries
29 entries across 29 versions & 1 rubygems