Ali Farhoudi
Ali Farhoudi

Reputation: 6020

How to remove git hooks

I had set up a git hook in pre-commit file to run git pull before any commit. Now I have deleted that file and restarted my computer multiple times, but that hook is still running before my commits.

How can I remove or disable that completely?

Upvotes: 160

Views: 163417

Answers (5)

Vytenis Bučius
Vytenis Bučius

Reputation: 177

first in terminal run this:

find .git/hooks

then remove hook such as:

rm .git/hooks/pre-push

Upvotes: 1

robothy
robothy

Reputation: 1320

git config --unset core.hookspath

Upvotes: 7

förschter
förschter

Reputation: 860

Alternatively there might be a path for hooksPath in your git config folder. You can open the config file in .git/config and remove or change the line starting with hooksPath.

Upvotes: 6

Ali Farhoudi
Ali Farhoudi

Reputation: 6020

I figured out what was causing that:
I had created my pre-commit hook in git core directory, but the git had created a pre-commit hook in project's .git/hooks/ directory. I just removed it.

It means running the command that @romin21 mentioned inside project's root directory:

rm -rf .git/hooks

Upvotes: 260

roger
roger

Reputation: 1141

Based on the documentation, git hooks should reside in $GIT_DIR/hooks/ - verify this dir does not contain the pre-commit hook file

If the problem persists, you could flag your git commit with --no-verify (that should bypass the pre-commit hook)

Information can be found at:

https://git-scm.com/docs/githooks

Upvotes: 43

Related Questions