当我使用git push、show、fetch、clone时,为什么总是会出现"fatal: does not appear to be a git repository"的错误提示?
我使用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目录。
然后它可以正常工作。
我可以克隆仓库。
然而,我仍然不能通过vsCode推送。
当我使用vsCode推送时,它会返回
Permission denied, please try again.
Permission denied, please try again.
user@dev.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)。
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists。
我猜这是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
命令创建了那个远程仓库吗? - Daemon Painter