コミット漏れやメッセージ内容の修正で git commit --amend
で対話形式で修正するときに、#1234
のようなチケット番号を先頭にいれているときのやり方のメモ。
デフォルトだと、#はコメントアウトの記号になるので、このままではうまくいかないです。
-
--cleanup=whitespace
を追加 -
git config core.commentchar ";"
などとしてコメントアウトの記号をかえる -
git commit --amend -m "#1234 hogehoge"
として対話式をあきらめる
--cleanup=whitespace
でコメント行を無視してメッセージを整形(余計なものを消す)する設定です。これをやると、先頭以外にもあるコメント行もメッセージとして採用されてしまうので注意が必要です。
参考サイト
- http://code.reeloo.net/2012/03/git-commit-message-starting-with-hash.html
- https://coderwall.com/p/gs_vzw/start-interactive-commit-messages-with-hash
- http://stackoverflow.com/questions/2788092/start-a-git-commit-message-with-a-hashmark
- http://rochefort.hatenablog.com/entry/2014/08/17/073000
- http://qiita.com/tunepolo/items/7303f56854feeba46c82