Reputation: 11683
I'm using git hooks for the first time and stuck on an issue that seems simple but I haven't found any answer so far.
I have created a shell script (it works fine when called directly) which I want to call inside the git post-commit-hook. I know I could include the script itself in the hook, but that could get chaotic if more scripts are added.
The contents of the hook-file looks like this:
!/bin/sh
sh myshellscript.sh # This doesn't work by the way
: Nothing
The hook is definitely executed but myshellscript.sh is not found.
Where is the best place to put myshellscript.sh and how do I reference it?
Thanks in advance!
Upvotes: 0
Views: 146
Reputation: 10173
The hook will be executed with the current directory set to $GIT_DIR
which is usually the root directory of the repository.
If your script, myshellscript.sh
, is in the hooks directory you would need to run
sh .git/hooks/myshellscript.sh
Upvotes: 1