I have set up a website on a server and use git to maintain it. For this reason I have created two git repositories, a bare one at $HOME/site
to which I push and a non-bare one at /var/www
which is supposed to pull from the bare repository every time a change is made.
In order to update the non-bare repository automatically, I have created and granted executon permission to a post-update
git hook in the bare repository that contains the following:
#!/bin/bash
cd /var/www
git pull
However, after every push to the bare repository I can see the following on my terminal:
remote: fatal: Not a git repository: '.'
Is there anything I have omitted or done wrong regarding this hook?
Try this. Add this line to your hook script before you do the git pull command:
unset $(git rev-parse --local-env-vars)
This will unset all GIT_XXX_YYY environment variables.
来源:https://stackoverflow.com/questions/6394366/problem-with-git-hook-for-updating-site