我有一个Docker镜像,应该从git仓库中提取仓库(关于 token 的提示来自pretty similar question)
运行git clone https://TOKEN@github.com/company/project.git / folder
然后工作正常。
CMD [“/update.sh”]
update.sh:
if [ -f /folder/.git ]; then
git clone https://TOKEN@github.com/company/project.git /folder
else
git -C /folder pull
fi
然后我收到一个非常奇怪的错误:
fatal: Not a git repository (or any of the parent directories): .git
我的google-fu能够找到的所有答案都是关于“我正在接收致命信息:运行git pull时不是git存储库”-如果您从错误的目录中提取信息,这很有意义。但是在我的情况下,git clone产生“致命的:不是git存储库”错误,这非常令人困惑。
最佳答案
两件事情:
-d
而不是-f
,因为.git
是目录而不是文件.git
不存在时,如果您实际上要克隆gitt_code,那么您正在尝试克隆git存储库。 关于git - Docker镜像git clone错误 “fatal: Not a git repository”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49846931/