Gabriel Devillers
Gabriel Devillers

Reputation: 4002

Disable hooks for a single git command

Given that I need to use git inside my hook scripts, I would prefer my hook scripts to not trigger hooks themselves. So I want to skip hooks on a per-command basis.

i.e. I am looking for an option like:

git --no-hooks some-git-command

Upvotes: 10

Views: 4718

Answers (3)

mystackoverflowpseudo
mystackoverflowpseudo

Reputation: 75

If you are on unix, and want to disable one or more hook, you can simply do a :

chmod -x .git/hooks/MYHOOK ; git COMMAND ; chmod +x .git/hooks/MYHOOK; 

Upvotes: 1

Ruslan Mavlyanov
Ruslan Mavlyanov

Reputation: 675

Another rougher idea.

  1. Just comment lines in file .git/hooks/pre-commit with symbol '#'.
  2. Run single or many commands
  3. Uncomment
  4. Profit.

Upvotes: 4

Gabriel Devillers
Gabriel Devillers

Reputation: 4002

You can use:

git -c core.hooksPath=/dev/null some-git-command

If you are not on an Unix (no /dev/null) I suppose that you can use:

git -c core.hooksPath= some-git-command

Upvotes: 11

Related Questions