Symbolic link to a hook in git

Mateusz Dymczyk picture Mateusz Dymczyk · Jan 4, 2011 · Viewed 25.9k times · Source

I wrote my own custom post-merge hook, now I added a "hooks" directory to my main project folder (since git doesn't track changes in .git/hooks), somewhere I read that I can make a symbolic link from hooks to .git/hooks so I don't have to copy the file from one folder to the other every time someone changes it so I tried:

ln -s -f hooks/post-merge .git/hooks/post-merge

But it doesn't seem to work, any ideas why? "ln hooks/post-merge .git/hooks/post-merge" works fine but making a hard link is the same as copyin I guess....

Answer

Michal Čihař picture Michal Čihař · Jan 4, 2011

you just used wrong path, it should be:

ln -s -f ../../hooks/post-merge .git/hooks/post-merge