美文网首页
shell判断git remote是否存在

shell判断git remote是否存在

作者: 南慕瑶 | 来源:发表于2020-06-01 21:20 被阅读0次

    假如,要判断的 remote 的名字为 faraway。

    【第一种方式】

    if git config remote.faraway.url > /dev/null; then 

     …

    fi

    【第二种方式】

    if git remote | grep faraway > /dev/null; then 

     ...

    fi

    【使用场景】

    判断 remote 是否已存在,如果已存在,直接进行 git fetch faraway 等操作,如果不存在,git add remote faraway http://xxxxx 后,再进行操作。

    #参考:

    https://stackoverflow.com/questions/12170459/check-if-git-remote-exists-before-first-push

    相关文章

      网友评论

          本文标题:shell判断git remote是否存在

          本文链接:https://www.haomeiwen.com/subject/tdkszhtx.html