无法推送到远程 GIT 存储库 - “[...] 似乎不是 git 存储库”

2024-04-30

我已经在我的服务器上使用适当文件夹中的以下内容设置了 GIT 存储库(我的子域的根目录,git.mydomain.com):

mkdir foo.git
cd foo.git
git init --bare --shared

这将使存储库可通过 URL 访问git.mydomain.com/foo.git.

在我的客户端上,尝试使用以下命令将提交的文件推送到服务器: mkdir foo

cd foo
git init
git remote add foo [email protected] /cdn-cgi/l/email-protection:foo.git
git add readme.txt
git commit -m "foo"
git push foo master
.. entering user password ..

只会导致:

fatal: 'foo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

然而,遵循一组不同的指南,我似乎无法解决这个问题。任何建议将不胜感激,请记住我对 GIT 很陌生。


线路git remote add foo [email protected] /cdn-cgi/l/email-protection:foo.git假设目录 foo.git 位于myUser用户。使用绝对路径会更好,例如git remote add foo [email protected] /cdn-cgi/l/email-protection:/home/gitrepos/foo.git

如果您位于共享服务器上,您可以通过执行以下命令来检查您的主路径:

echo $HOME

就我而言,这会产生:

首页/u/01234/

如果我将存储库存储在主路径中的 www/git/ 文件夹中,则命令可能如下所示:

git remote add origin [email protected] /cdn-cgi/l/email-protection:/home/u/01234/www/git/foo.git
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法推送到远程 GIT 存储库 - “[...] 似乎不是 git 存储库” 的相关文章

随机推荐