git忽略配置core.ssh命令,但可以与GIT_SSH_COMMAND =一起正常工作

Gun*_*ick 1 git ssh

我想使用配置来设置sshCommand而不是环境变量。但不起作用这是发生了什么

?  GIT_SSH_COMMAND='ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null' git ls-remote 
From git@github.com:syn2cat/Level2.lu.git
fcaa5a2e63499568dd916e7b18f950b311781bd0    HEAD
fcaa5a2e63499568dd916e7b18f950b311781bd0    refs/heads/master
a542061a64d3698d5da54d63456b26932fe549a2    refs/pull/1/head

?  git config core.sshcommand                                                           
ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null
?  git ls-remote
Permission denied (publickey).
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)

并进行调试,它不使用core.sshCommand中的值

? GIT_TRACE=1 git ls-remote 
13:46:15.366401 git.c:344               trace: built-in: git 'ls-remote'
13:46:15.366564 run-command.c:334       trace: run_command: 'ssh' 'git@github.com' 'git-upload-pack '\''syn2cat/Level2.lu.git'\'''
Run Code Online (Sandbox Code Playgroud)

版本号

?  lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial
?  git --version
git version 2.7.4
Run Code Online (Sandbox Code Playgroud)

bk2*_*204 6

core.sshCommand选项已添加到git 2.10.0中。您正在运行2.7.4,但没有该功能。如果要使用它,则需要升级到较新的Git。

  • 我尝试了使用“export GIT_SSH_COMMAND”的“ENV”方法和使用“git config --global core.sshCommand”的配置方法,但都失败了。事实证明,我使用的“docker”镜像是基于“debian/jessie”的,并且它有“git 2.1”。我花了几个小时对错误的地方进行故障排除!谢谢@布莱恩 (2认同)