2

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!

4
  • I just made a new repository and the pre-push.sample file doesn't have execute permissions. Maybe that's what's getting you? Commented May 28, 2013 at 21:32
  • Thanks! How would i fix that? @CarlNorum Commented May 28, 2013 at 21:34
  • I just did some more testing, it's likely that's what's getting you. Writing an answer now. Commented May 28, 2013 at 21:37
  • I ran the line chmod +x pre-push but it still doesn't work. Commented May 28, 2013 at 21:38

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes it works on brand new repositories. But my question is how do you add a pre-push hook to an existing repository made from an older git version. It doesn't work when I create the file and run the chmod command. It gives me that error above.
Hm, I tried here and it seems to work fine. I have 1.8.3, though. Maybe it's a message from your script, rather than from git? Can you show the script's contents?
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.