Skip to content

Instantly share code, notes, and snippets.

@ykyk1218
Created October 29, 2014 13:53
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 ykyk1218/67ed2f542b092c53edb0 to your computer and use it in GitHub Desktop.
Save ykyk1218/67ed2f542b092c53edb0 to your computer and use it in GitHub Desktop.
Gitでcommitした時にブランチ名をcommitメッセージに自動でいれる ref: http://qiita.com/ykyk1218/items/4c17eef472ae8c31991f
$ vi .git/hook/prepare-commit-msg
#!/usr/bin/env ruby
#今いるブランチ名を取得
current_branch = `git branch | grep '*'`.chomp.sub('* ', '')
commit_msgs = File.readlines(ARGV[0])
open(ARGV[0], 'w') {|file|
file.print "#{current_branch}:"
file.puts commit_msgs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment