Costa Michailidis
Costa Michailidis

Reputation: 8178

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.

Upvotes: 0

Views: 471

Answers (1)

twalberg
twalberg

Reputation: 62459

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

Upvotes: 2

Related Questions