Skip to content

Instantly share code, notes, and snippets.

@juliengdt
Created August 27, 2014 07:48
Show Gist options
  • Save juliengdt/bcea5e8b7a3f24fd335b to your computer and use it in GitHub Desktop.
Save juliengdt/bcea5e8b7a3f24fd335b to your computer and use it in GitHub Desktop.
Hook system in Git

commit-msg - The Hook

Hooks are plugins which can be launch by git, on a special event. The commit-msg hook, if defined, is launched when user want commit

It's a git-enforced policy, used in entreprise to force dev to correctly format their commit messages

A custom one

Here is a custom commit-msg hook which looks for a format like these both:

  • [ADD] - It's a message where i add something
  • [JIRA] #456 - I correct this jira

@see this snippet

How-To

  • cd the-path-of-your-project
  • cd .git/hooks
  • touch commit-msg
  • nano commit-msg
  • Do your stuff or copy/past this snippet.
  • exit edit mode
  • chmod +x commit-msg
  • Have fun =]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment