Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set GIT_SSH Environment Variable in Gitconfig

Tags:

git

git-config

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

like image 917
voltair Avatar asked Aug 04 '13 21:08

voltair


People also ask

What is Git_ssh?

GIT_SSH , if specified, is a program that is invoked instead of ssh when Git tries to connect to an SSH host. It is invoked like $GIT_SSH [username@]host [-p <port>] <command> .


1 Answers

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
like image 51
VonC Avatar answered Oct 06 '22 08:10

VonC