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

Version Path
geordi-0.15.3 bin/remotify-local-branch
geordi-0.15.2 bin/remotify-local-branch
geordi-0.15.1 bin/remotify-local-branch
geordi-0.15.0 bin/remotify-local-branch
geordi-0.14.9 bin/remotify-local-branch
geordi-0.14.8 bin/remotify-local-branch
geordi-0.14.7 bin/remotify-local-branch
geordi-0.14.6 bin/remotify-local-branch
geordi-0.14.5 bin/remotify-local-branch
geordi-0.14.4 bin/remotify-local-branch
geordi-0.14.3 bin/remotify-local-branch
geordi-0.14.2 bin/remotify-local-branch
geordi-0.14.1 bin/remotify-local-branch
geordi-0.14.0 bin/remotify-local-branch
geordi-0.13.3 bin/remotify-local-branch
geordi-0.13.2 bin/remotify-local-branch
geordi-0.13.1 bin/remotify-local-branch
geordi-0.13.0 bin/remotify-local-branch
geordi-0.12.8 bin/remotify-local-branch
geordi-0.12.7 bin/remotify-local-branch