致命:似乎不是 git 存储库

Mar*_*rio 6 server repository git

我在我的生产服务器上设置了一个空的 git repo

git init --bare
Run Code Online (Sandbox Code Playgroud)

在我的本地机器上,我将 repo 添加为远程:

git remote add origin ssh://user@example.com/~/git/example.com
Run Code Online (Sandbox Code Playgroud)

如果我发出以下命令

git remote show origin
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息说:

fatal: '~/git/example.com' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我尝试了此处提到的冒号,但没有帮助。

mur*_*uru 6

使用 SSH URL,相对路径从您的主目录开始,并且它不理解像~. 所以这样做:

git remote add origin ssh://user@example.com/git/example.com
Run Code Online (Sandbox Code Playgroud)

如果要使用绝对路径,例如/home/mario/git/example.com,请使用额外的前导斜杠:

git remote add origin ssh://user@example.com//home/mario/git/example.com
Run Code Online (Sandbox Code Playgroud)


cot*_*eyr 0

这意味着远程服务器在 ~/git/example.com 上没有存储库,我怀疑您的地址错误。大多数 git 地址类似于 git@server.com:project.git。大多数没有路径或参考〜