【问题标题】:Check whether a git remote is reachable检查git远程是否可达
【发布时间】:2019-01-22 09:11:36
【问题描述】:

在 bash 脚本中,我想像这样循环遍历所有 git 遥控器

for remote in $(git remote)
do
  git remote prune $remote
done

问题在于,在我的情况下,用于当前不可用遥控器的git remote 命令不会在合理的时间内超时,而是挂起。

如何编写脚本以使其忽略当前不可用的 git 遥控器?

更新:

git 连接是通过 ssh 发生的。

【问题讨论】:

标签: bash git ssh


【解决方案1】:

假设您使用ssh 进行连接,是否值得为ssh 配置超时,所以不良连接至少最终会失败?当然对于我的命令行sshConnectTimeout 似乎没有设置:

$ ssh -G git.example.com | grep -i ConnectTimeout
connecttimeout none

ConnectTimeout 设置在man ssh_config 中进行了描述,通常只是放入~/.ssh/config

ConnectTimeout 30

【讨论】:

    猜你喜欢
    • 2019-01-18
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 2014-05-19
    • 1970-01-01
    • 2014-09-17
    相关资源
    最近更新 更多