[英]Git fetch command succeeds at command line but fails in bash script
git fetch someremote # the remote is on github.com, and using SSH
如果我从终端发出上述命令,则该命令成功,但是如果将其放入bash脚本中,它将失败,并显示:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我希望这能给某人一些线索,以帮助弄清为什么它在bash脚本中失败,但在终端成功! 有人知道吗
如果我使用SSH或HTTPS,似乎也会发生同样的事情
您的环境变量可能有问题。 为什么不尝试diff
它们呢?
$ echo "printenv | sort > /tmp/script.env" > /tmp/envtest.sh
$ bash /tmp/envtest.sh
$ printenv | sort > /tmp/term.env
$ diff /tmp/term.env /tmp/script.env
在我的终端中,我得到:
76c76
< SHLVL=1
---
> SHLVL=2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.