DEV Community

loading...

Discussion on: Git Hooked on Git Hooks

Collapse
jrock2004 profile image
John Costanzo

This is great for yourself, but the next question, is how do you share this between team members? How do I back these up so I do not lose them if I reformat?

Collapse
rpalo profile image
Ryan Palo Author

There are a couple of ways that I've found to do this.

  1. Create a separate directory such as ./hooks to hold your hooks. Then use a setup script to copy them into your .git/hooks directory after cloning. (i.e. git clone ... && ./setup.sh)

  2. If you're on Git 2.9 or later, there is a config setting to hook that up. git config core.hooksPath hooks. You can similarly add this line to any makefile/init/setup script.

  3. If you're doing JavaScript, there's shared-git-hooks as well.

Let me know if you find a better way!

Collapse
jrock2004 profile image
John Costanzo

Yeah, where my concern is, making sure developers do this when they first clone the repo. I will keep looking

Thread Thread
gyandeeps profile image
Gyandeep Singh

If your work on javascript projects, then using github.com/typicode/husky would solve all those problems. npm install hooks up everything for every developer. In JS, you have to run npm install to get started on a project.

Thread Thread
jrock2004 profile image
John Costanzo

Thank you very much