I want to call a Script that is located in the repository.
I could of course do the following:
#!/bin/sh
../../myscript.sh
but I think thats not nice 😉
so how do I get the path of my project within the post-commit script?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you’re dealing with a non-bare repository, the
post-commit1 hook is run with a current working directory of the working tree of the repository. So, you don’t need the../../.If you want the full path of the script, you could always do:
… or you could use
git rev-parse --show-toplevelto get an absolute path to the working directory:1 … but note that this is not true of some other hooks, e.g. in a
post-receivehook in a non-bare repository, the current working directory is the.gitdirectory.