git 在 Gitconfig 中设置 GIT_SSH 环境变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18047652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set GIT_SSH Environment Variable in Gitconfig
提问by voltair
Is there a way to set the GIT_SSH environment variable in the gitconfig file?
有没有办法在 gitconfig 文件中设置 GIT_SSH 环境变量?
采纳答案by VonC
Since my 2013 answer(Git 1.8.3.4), a new configuration has been set: core.sshCommand
自从我 2013 年的回答(Git 1.8.3.4)以来,已经设置了一个新的配置:core.sshCommand
If this variable is set,
git fetch
andgit push
will use the specified command instead ofssh
when they need to connect to a remote system.
The command is in the same form as theGIT_SSH_COMMAND
environment variable and is overridden when the environment variable is set.
如果这个变量被设置,
git fetch
并且git push
将使用指定的命令而不是ssh
当它们需要连接到远程系统时。
该命令与GIT_SSH_COMMAND
环境变量的形式相同,并在设置环境变量时被覆盖。
It has been introduced in Git 2.10, commit 3c8ede3, June 2016
它已在Git 2.10 中引入,提交 3c8ede3,2016 年 6 月
Since then, you have Git 2.13, commit dd33e077, Feb. 2017, which has ssh.variant
从那以后,你有了Git 2.13,提交 dd33e077, Feb. 2017,它有ssh.variant
Depending on the value of the environment variables
GIT_SSH
orGIT_SSH_COMMAND
, or the config settingcore.sshCommand
, Git auto-detects whether to adjust its command-line parameters for use with plink or tortoiseplink, as opposed to the default (OpenSSH).The config variable
ssh.variant
can be set to override this auto-detection; valid values aressh
,plink
,putty
ortortoiseplink
.
Any other value will be treated as normal ssh. This setting can be overridden via the environment variableGIT_SSH_VARIANT
.
根据环境变量
GIT_SSH
或的值GIT_SSH_COMMAND
,或配置设置core.sshCommand
,Git 自动检测是否调整其命令行参数以用于 plink 或 tortoiseplink,而不是默认值 (OpenSSH)。
ssh.variant
可以设置配置变量来覆盖此自动检测;有效值为ssh
,plink
,putty
或tortoiseplink
。
任何其他值都将被视为正常的 ssh。可以通过环境变量覆盖此设置GIT_SSH_VARIANT
。
For those, I need to use the SSH client that Git for Windows came with
对于那些,我需要使用 Git for Windows 附带的 SSH 客户端
So for the repos where you need ssh instead of putty, you can use both settings to set exactlyin your configuration what you want.
因此,对于需要 ssh 而不是 putty 的存储库,您可以使用这两种设置在您的配置中准确设置您想要的内容。
cd /path/to/my/repo
git config ssh.variant ssh
回答by VonC
GIT_SSH
isn't mentioned in the git config
man page.
GIT_SSH
git config
手册页中没有提到。
"Git clone with custom SSH using GIT_SSH error" describes how to pass option to GIT_SSH
, but illustrates that it isn't part of a git repo config.
“使用 GIT_SSH 错误使用自定义 SSH 的 Git 克隆”描述了如何将选项传递给GIT_SSH
,但说明它不是 git repo 配置的一部分。