Restrict Git commit message to certain pattern
For certain reason, some time you want your commit message to follow a standard pattern.
i.e. PJK-001: my message
Want to have a project code and assignment code there.
Now, open up your project git directory.
i.e. /path/to/your/project/.git/hooks/
and edit commit-msg file (if doesn’t exist, create it)
(NOTE: This example I’ll write in Python)
1 | #!/usr/bin/python |
Simple right? But don’t remember to change it to executable and no .py
extension
1 | $ chmod 755 /path/to/your/project/.git/hooks/commit-msg |
References: