在Gitconfig中设置GIT_SSH环境变量 [英] Set GIT_SSH Environment Variable in Gitconfig

查看:426
本文介绍了在Gitconfig中设置GIT_SSH环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在gitconfig文件中设置GIT_SSH环境变量?

解决方案

我的2013年回答(Git 1.8.3.4 ),则设置了新的配置: core.sshCommand

如果设置了此变量,则在需要连接到远程系统时,git fetchgit push将使用指定的命令而不是ssh. 该命令与GIT_SSH_COMMAND环境变量的格式相同,并且在设置环境变量时将被覆盖.

已在 Git 2.10,提交3c8ede3,2016年6月

从那时起,您 Git 2.13,提交dd33e077,2017年2月,其中具有 ssh.variant

根据环境变量GIT_SSHGIT_SSH_COMMAND的值或配置设置core.sshCommand,Git自动检测是否调整其命令行参数以用于plink或tortoiseplink,而不是默认(OpenSSH).

可以将配置变量ssh.variant设置为覆盖此自动检测; 有效值是sshplinkputtytortoiseplink.
任何其他值将被视为普通ssh.可以通过环境变量GIT_SSH_VARIANT覆盖此设置.


对于这些,我需要使用Git for Windows随附的SSH客户端

因此对于需要ssh而不是腻子的仓库,您可以使用这两种设置在您的配置中精确地设置 .

 cd /path/to/my/repo
 git config ssh.variant ssh

Is there a way to set the GIT_SSH environment variable in the gitconfig file?

解决方案

Since my 2013 answer (Git 1.8.3.4), a new configuration has been set: core.sshCommand

If this variable is set, git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system.
The command is in the same form as the GIT_SSH_COMMAND environment variable and is overridden when the environment variable is set.

It has been introduced in Git 2.10, commit 3c8ede3, June 2016

Since then, you have Git 2.13, commit dd33e077, Feb. 2017, which has ssh.variant

Depending on the value of the environment variables GIT_SSH or GIT_SSH_COMMAND, or the config setting core.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 are ssh, plink, putty or tortoiseplink.
Any other value will be treated as normal ssh. This setting can be overridden via the environment variable GIT_SSH_VARIANT.


For those, I need to use the SSH client that Git for Windows came with

So for the repos where you need ssh instead of putty, you can use both settings to set exactly in your configuration what you want.

 cd /path/to/my/repo
 git config ssh.variant ssh

这篇关于在Gitconfig中设置GIT_SSH环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆