我做一些脚本:Git里,克隆与特定的私钥,sh.exe找不到文件
#!/bin/bash
#####
dest_branch="4.0.8_copy"
source="sprint24_copy"
#####
dest=$dest_branch
source=$source_branch
startDir=`pwd`
sshFile=$startDir"/git_ssh.ssh"
gitrepo="<some valid repo adress>"
git_key=$startDir"/key.ssh"
sshKey="-----BEGIN RSA PRIVATE KEY-----
MIIJJwIBAAKCAgEAs7Rfpca8s4.... and rest of key"
echo $sshKey > $git_key
echo "ssh -i "$git_key" \[email protected] "> $sshFile
export GIT_SSH=$sshFile
export GIT_TRACE=1
git clone [email protected]$gitrepo -b $dest
我运行混帐击(C这个脚本:\ Program Files文件\的Git \ BIN \ sh.exe ),并且该脚本失败,这一点错误:
Cloning into 'neos'...
10:44:26.575804 run-command.c:343 trace: run_command: 'C:/Users/<some user>/Desktop/<some dir>/git_ssh.ssh' '[email protected]<some valid adress>' 'git-upload-pack '\''<some project>'\'''
error: cannot spawn C:/Users/<some user>/Desktop/<some dir>/git_ssh.ssh: No such file or directory
fatal: unable to fork
我试图改变命令pwd
静态路径,如C:/ ... C:/ .../C/... \ C。 C:... C:...但仍然表现不佳。可以anybady帮我具体的另一个私人密钥克隆git回购?为什么这个sh.exe看不到我的文件?我确定该文件存在。我使用git版本2.6.4.windows.1。感谢您的帮助,并对我的英语感到抱歉。
从未在Windows上尝试过Git。对于bash的正常调试是将shebang更改为'#!/ bin/bash -x'并查看输出以验证所有内容都按预期进行了扩展。对于sshKey-assignment,可以查看heredocs来存储多行字符串,例如http://stackoverflow.com/questions/23929235/bash-multi-line-string-with-extra-space –
使用'ssh_config' – Jakuje