git 推送时出现 SSH "no such file or directory" 错误

SSH "no such file or directory" error on git push

我有一个位于 ~/.ssh/github_rsa 的私钥,相应的 public 密钥已上传到我的 Github 帐户。我创建了一个存储库并将其设置为我正在使用的目录的远程目录,在该目录的 .git 文件夹中,我有以下 config 文件:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    sshCommand = 'ssh -i ~/.ssh/github_rsa -o IdentitiesOnly=yes'
[remote "repoName"]
    url= git@github.com:myusername/repoName.git
    fetch = +refs/heads/*:refs/remotes/repoName/*

当我 运行 git push -u repoName main 时,出现以下错误:

'ssh -i ~/.ssh/github_rsa -o IdentitiesOnly=yes': line 1: ssh -i github_rsa -o IdentitiesOnly=yes: No such file or directory
fatal: Could not read from remote repository.

删除 -o IdentitiesOnly=yes 无效。将密钥的权限从 600 更改为 400 也没有效果。该文件肯定存在,并且存在于该路径中。

gitconfig 不识别单引号。使用双引号。

[core]
    sshCommand = "ssh -i ~/.ssh/github_rsa -o IdentitiesOnly=yes"