141

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?

James K
  • 3,692
  • 1
  • 28
  • 36
Ali Farhoudi
  • 5,350
  • 7
  • 26
  • 44

4 Answers4

217

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
Ali Farhoudi
  • 5,350
  • 7
  • 26
  • 44
39

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

roger
  • 1,091
  • 1
  • 7
  • 15
  • 1
    Thanks roger. I had created ```pre-commit``` hook based on ```pre-commit.sample``` in ```$GIT_DIR/hooks/``` and then I removed it. I even searched for hook using ```locate pre-commit``` and there's nothing left, but it's running yet. – Ali Farhoudi Oct 11 '16 at 15:45
  • 1
    `--no-verify` is only partially helpful. If you want to do `git checkout` or wanna do `git rebase -i`, and those commits won't be allowed, there's nothing you can do. – Danon Jan 30 '19 at 12:38
4

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.

förschter
  • 740
  • 1
  • 7
  • 24
2
git config --unset core.hookspath
robothy
  • 1,132
  • 11
  • 18