VarunMurali
VarunMurali

Reputation: 413

How to add a pre-push git hook to an existing repository?

I have a repository that I created with git version 1.7.12.

However, I have updated to version 1.8.2.3. This has the hook pre-push. Newly created repositories with this version use the pre-push hook. However when I add the pre-push to an existing repo, I get the following error:

fatal: cannot exec '.git/hooks/pre-push': Not a directory

Any help?

Thanks!

Upvotes: 2

Views: 2196

Answers (2)

mustard
mustard

Reputation: 783

run "git init" to re-initialize your local git repository.

Upvotes: 0

Carl Norum
Carl Norum

Reputation: 224864

I just made a brand new repository, and the pre-push.sample is there, as you say. It for some reason doesn't have execute permission set, though, so it doesn't work when renamed to pre-push. If you add execute permission:

chmod +x .git/hooks/pre-push

You should be ok. The provided sample had a bash if/then bug too. Changing line 32 from:

# Handle delete

to:

: # Handle delete

fixed it for me.

Upvotes: 3

Related Questions