Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created January 6, 2015 02:49
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 fujimura/87ce58d7bfa7dadefea2 to your computer and use it in GitHub Desktop.
Save fujimura/87ce58d7bfa7dadefea2 to your computer and use it in GitHub Desktop.
post-checkout hook to prevent from checking out master
#! /usr/bin/env ruby
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
end
current_branch = `git branch | grep '*' | awk '{ print \$2 }'`.chomp
if current_branch == 'master'
`git checkout develop`
puts "You are trying to checkout `master`, but our default branch is `develop`. Now this post-commit checked out `develop` to not break `master`.".red
puts "If you really want to checkout `master`, please modify this file(#{File.expand_path(__FILE__)}).".red
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment