这很奇怪但是在设置git存储库并创建一个post-receive hook时:
- echo "--initializing hook--"
- cd ~/websites/testing
- echo "--prepare update--"
- git pull
- echo "--update completed--"
钩子确实运行,但它从来没有设法正确运行git pull:
- 6bfa32c..71c3d2a master -> master
- --initializing hook--
- --prepare update--
- fatal: Not a git repository: '.'
- Failed to find a valid git directory.
- --update completed--
所以我现在问自己,如何通过post-receive使钩子更新克隆?
在这种情况下,运行进程的用户是相同的,它的所有内容都在用户文件夹中,所以我真的不明白…因为如果我手动进入
- cd ~/websites/testing
- git pull
它没有任何问题……
任何帮助都会非常感激
非常感谢
挂钩正在运行时,GIT_DIR和(如果显式定义了工作树)GIT_WORK_TREE已设置.这意味着您的pull不会与您更改的目录中的第二个存储库一起运行.
试试git –git-dir~ / websites / testing / .git –work-tree~ / websites / testing pull;或者取消设置git的repo-local环境:
- unset $(git rev-parse --local-env-vars)
有关这些环境变量的更多信息,请参见man 1 git.