How to enforce conventional commit messages in git (Bitbucket)

Viewed 795

I'm looking for a way to prevent commits which have no correct format for the commit message.
I intend to use the following convention:
https://www.conventionalcommits.org/en/v1.0.0/

I found out there is a folder with bash scripts which may be the key to that solution: .git/hooks/

However, I'm not sure how to write the script to enforce the format on the commit messages.

Will edit accordingly, thank you in advance.

1 Answers

There is a list of Tools in the documentation.

My suggestion would be to:

  1. Pick a tool.
  2. Run it from the command line, and see if you can get it to check commit messages.
  3. Put the commands you use to check commits messages in a git hook.
Related