【发布时间】:2016-04-27 12:39:13
【问题描述】:
我做了一些脚本:
#!/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" \$@ "> $sshFile
export GIT_SSH=$sshFile
export GIT_TRACE=1
git clone git@$gitrepo -b $dest
我在 Git Bash (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' 'git@<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:... 但是仍然失败。任何人都可以帮我指定另一个私钥来克隆 git repo 吗?为什么这个 sh.exe 看不到我的文件?我确定该文件存在。我使用 git 版本 2.6.4.windows.1。感谢您的帮助,对我的英语感到抱歉。
【问题讨论】:
-
从未在 Windows 上尝试过 git。 bash 的正常调试是将 shebang 更改为
#!/bin/bash -x并查看输出以验证所有内容是否按预期扩展。对于 sshKey-assignment,请查看 heredocs 以存储多行字符串,例如stackoverflow.com/questions/23929235/…
标签: git bash shell ssh mingw-w64