Costa Costa - 7 months ago 52
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.


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...