Costa Costa - 1 year ago 84
Git Question

Do git hooks (pre-commit, post-commit, etc) apply to all branches?

So, they do, I checked.

How do I get them to only run on certain branches? Or am I bonkers for wanting that?

I'm not working on a specific project at the moment. I'm exploring static site generators, hosting on AWS S3, and learning about potential workflows for this paradigm.

Answer Source

You could use something like git rev-parse --symbolic --branches in your hook script to determine what branch you are on and adjust your logic accordingly.

It does seem to be a rather odd requirement, though. Perhaps if you described the requirements you're trying to address, there might be alternative approaches...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download