Skip to content

Instantly share code, notes, and snippets.

@andywenk
Created September 4, 2014 10:35
Show Gist options
  • Save andywenk/74da349b0ae49448b366 to your computer and use it in GitHub Desktop.
Save andywenk/74da349b0ae49448b366 to your computer and use it in GitHub Desktop.
rake task to compare remote and local git branches
task :compare_remote_and_local_branch do
sh "git remote update"
current_branch = `git rev-parse --abbrev-ref HEAD`
local_commit_hash = `git rev-parse HEAD`
remote_commit_hash = `git rev-parse origin/#{current_branch}`
print "#{Term::ANSIColor.green}[INFO]: branch: #{current_branch}#{Term::ANSIColor.reset}"
print "#{Term::ANSIColor.green}[INFO]: local commit hash: #{local_commit_hash}#{Term::ANSIColor.reset}"
print "#{Term::ANSIColor.green}[INFO]: remote commit hash: #{remote_commit_hash}#{Term::ANSIColor.reset}"
if local_commit_hash == remote_commit_hash
puts "#{Term::ANSIColor.green}[STOP]: local und remote sind gleich.#{Term::ANSIColor.reset}"
exit()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment