【发布时间】:2020-06-11 10:15:48
【问题描述】:
为什么我在使用 git push、show、fetch、clone 时总是得到“致命:似乎不是 git 存储库”。
我使用 repo 作为我的裸存储库。
git remote add origin user@dev.com:/home/administration/repo
git push origin master
fatal: '/home/administration/repo' does not appear to be a git repository
fatal: Could not read from remote repository.
我已经用我的远程 url 尝试了很多模式。
喜欢
user@dev.com/home/administration/repo
user@dev.com//home/administration/repo
ssh://user@dev.com/home/administration/repo
但是,所有的结果都是一样的。
步骤:
-Server(user@dev.com/home/administration/)
$ mkdir repo
$ cd repo
$ git init --bare
Initialized empty Git repository in /home/administration/repo/
$ ls -a
. .. branches config description HEAD hooks info objects refs
-local
$ git clone user@dev.com:/home/administration/repo
warning: You appear to have cloned an empty repository.(repo directory has been created at local)
$ cd repo
$ git remote add origin user@dev.com:/home/administration/repo
$ git remote -v
origin user@dev.com:/home/administration/repo (fetch)
origin user@dev.com:/home/administration/repo (push)
我只是删除了我在本地由 vsCode 创建的 .git 目录。
然后就可以了。
我可以克隆 repo。
但是,我还是无法通过 vsCode 推送。
当我使用 vsCode 推送时,它返回
权限被拒绝,请重试。
权限被拒绝,请重试。
user@dev.com:权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic、密码)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限并且存储库存在。
我猜是 ssh 的密码问题,但是我在 vsCode 中无法输入密码。
我试试@VonC的方法
我的操作系统是 Win10
-local
> ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa_ubuntu.
Your public key has been saved in /home/username/.ssh/id_rsa_ubuntu.pub.
The key fingerprint is:
SHA256:nNnQckFbuegUs4WD3y+7YqwCaDhfUlX2J17jxF7X3FU xenby@demo.com
The key's randomart image is:
+---[RSA 2048]----+
| .o++ .. E|
| . *o+. ..|
| . = *+ o ..|
| . . Ooo+ * +|
| . o Soo..B o.|
|o + o . ..o |
| + o . . . . |
| . . + o |
| ..o .o. |
+----[SHA256]-----+
> cp C:\Users\UserName\.ssh\id_rsa.pub C:\Users\UserName\authorized_keys
-Server
> mkdir ~/.ssh
-local(Windows doesn't exist "ssh-copy-id",so I use scp)
> scp authorized_keys user@dev.com:~/.ssh
user@dev.com's password:
-Server
> chmod 700 ~/.ssh
> chmod 600 ~/.ssh/authorized_keys
做完这些事情后,我在使用 ssh user@dev.com 时仍然需要输入密码......
我的问题是什么?
【问题讨论】:
-
您是否将远程创建为
git init --bare? -
目标 repo 文件夹是否包含 .git 文件夹?
-
您可以点击:“git config --list”命令并显示结果吗?和“git show”命令。
-
@DaemonPainter 是的,我做到了。
-
据我所见,该 URL 已正确解析,但指向的不是 git 存储库。