I try to understand problem. I have some observation.
I use git.exe. git.exe uses Windows path, but MinGW uses both, and ssh uses only linux :X
When I try use GIT_SSH='path to scrip', then git uses some like ConvertToWindowsPatch(GIT_SSH). Finally git finds script, but now SSH can not finds file with key !
When I try GIT_SSH='ssh -vvv' to debug I see
bash: ssh: command not found
First I think wtf... but I see that ssh is an alias ! So I use GIT_SSH='ssh.exe -vvv' and now it work. Unfortunately I can not resolve my problem that ssh do not see my file with key, but I know, if I write file to C:\, then in C this file doesn't exists ! This file is in C:\Users\\AppData\Local\VirtualStore . I don't know how can I save my ssh key in file and ssh can see it but I have other solve.
Before my main funcion of script, I backup .ssh folder. Then I write id_rsa in .ssh, and known_host. Then I want git clone, but ssh ask me about passphrase ... BUT THIS KEY HAVE NOT PASS !!. Ok calm down. When I try ssh.exe -vvv I see that sshKey haven't header, because I write this key without newlines ! I have this :
echo $sshKey > $sshKeyFile
but correct is
echo "$sshKey" > $sshKeyFile
Now all work correctly. I see 2 WTF - first ssh don't see files in MinGW, second if ssh don't see header of key without -vvv don't see this but ask about pass (wtfwtfwtfwtfwtf...)
This is correct script to manipulate git repo ( merge, push etc... ) in bash using MinGW, git and Windows, with specific rsa private key. I use it to automatic marge and create branches in Jenkins on Windows.
#!/bin/bash
#####
dest_branch="4.0.8_copy"
source="sprint24_copy"
#####
dest=$dest_branch
source=$source_branch
sshDir="/c/Users/<user>/.ssh"
gitrepo="<repo>"
sshKeyFile=$sshDir"/id_rsa"
knownHostsFile=$sshDir"/known_hosts"
sshKey="-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEApH0bkaXa0z7811Sd1ZEG87adPPNWyaya47T3GrCjjnRvVyEk
N8jGjh/..."
knownHosts="<some host> ecdsa-sha2-nistp256 AAAAE2VjZ..."
if [ -a $sshDir ] ; then
echo "backup .ssh"
cp -r $sshDir $sshDir"_back"
echo "usuwanie starego .ssh"
rm -r $sshDir
echo "tworzenie nowego .ssh"
mkdir $sshDir
echo "zapis klucza rsa"
echo "$sshKey" > $sshKeyFile
echo "zapis znanyn hostów"
echo $knownHosts > $knownHostsFile
echo "wlaczenie debugu gita"
export GIT_TRACE=2
echo "wlaczenie debugu
echo "clone repo"
git clone git@$gitrepo -b $dest
#other git operations
echo "usuwanie tymczasowego .ssh"
rm -r $sshDir
echo "odtwrzanie z backupu .ssh"
cp -r $sshDir"_back" $sshDir
echo "usuwanie backupu"
rm -r $sshDir"_back"
fi
Thanks for help and comment !