Janek
Janek

Reputation: 1491

Sending environmental variable with git client when using ssh

I would like to be able to send an environmental variable when invoking, for example git clone over ssh:

git clone ssh://host.example/project

I know that this can be achieved by setting the SendEnv in ~/.ssh/config for host.example. Although I would like to avoid modifying any files. For example, with only ssh we could do:

ssh -o SendEnv=MYVAR server.example.com mycommand

and no file modification is necessary. Is there a similar way to achieve this when using git clone over ssh?

Cheers!

Upvotes: 0

Views: 240

Answers (1)

Mark Leighton Fisher
Mark Leighton Fisher

Reputation: 5693

A Bash shell function can do this:

function e { echo $1; GIT_SSH=$1; export GIT_SSH; }

Substitute whatever Git functionality you need for the "echo $1".

Upvotes: 2

Related Questions