konzepz konzepz - 4 months ago 12
Git Question

How to add Git's branch name to the commit message?

I need some help with a Bash script that will automatically add the git's branch name as a hash in commit messages.


Use the prepare-commit-msg or commit-msg githook.

There are examples already in your PROJECT/.git/hooks/ directory.

As a security measure, you will have to manually enable such a hook on each repository you wish to use it. Though, you can commit the script and copy it on all clones into the .git/hooks/ directory.