【发布时间】:2018-01-27 15:56:50
【问题描述】:
我正在使用(相对)新的 Git sshCommand:
git config core.sshCommand 'ssh -i ~/Documents/keydir/key.pem'
这会产生以下配置:
sshCommand = ssh -i ~/Documents/keydir/key.pem
但是当我尝试推送到服务器时(顺便说一句,我使用的是主目录。它必须是 www 目录吗?)
[remote "origin"]
url = ssh://ubuntu@myserver.com:22/home/ubuntu/myrepo.git
或
[remote "origin"]
url = ssh://ubuntu@myserver.com/home/ubuntu/myrepo.git
它返回:
git push remote master
fatal: 'remote' does not appear to be a git repository
fatal: Could not read from remote repository.
...错误。
一直想不通。
我尝试过使用“~/myrepo.git”和“/home/ubuntu/myrepo.git”,也尝试过“url = ssh://ubuntu@myserver.com:/home/ubuntu/ myrepo.git"
我也尝试在 /var/www 文件夹中启动一个新的 git...
似乎没有任何效果。 myrepo.git 肯定在 ubuntu 主文件夹中。
有什么想法吗?
编辑:我完整的 .git/config 文件:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
sshCommand = ssh -i ~/Documents/keydir/key.pem
[remote "origin"]
url = ssh://ubuntu@myserver.com:22/home/ubuntu/mygit.git
fetch = +refs/heads/*:refs/remotes/origin/*
编辑:将本地 (2.5.4) 和远程 (2.7.4) 版本的 Git 更新到最新版本 (2.16.1) 解决了这个问题。
【问题讨论】: