unix – Git – 带git pull的post-receive hook“无法找到有效的git目录”

这很奇怪但是在设置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.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...