Search code examples
gitcommitcommit-message

Commit message prefix in git


I have a requirement to prepend "ticket:N" to commit messages, where N is the number of the ticket I'm working on. But I keep forgetting about the prefix and remember about it only 5-6 commits later, so --amend won't help. Is it possible to set some warning, so git will warn me every time I forget to add the prefix?


Solution

  • To make sure every commit message follows some standard form, you can use the commit-msg hook.

    But if you want to edit the commit message of some commit that is not the most recent, you can do that too using git rebase -i, assuming you didn't push it yet.