创建shell脚本以克隆多个git存储库并签出特定标记

创建shell脚本以克隆多个git存储库并签出特定标记,git,bash,Git,Bash,我需要一个shell脚本,它可以读取包含git存储库url和所需标记的文件,从url克隆存储库并签出列出的标记 示例结构: 等等 有什么想法吗?像这样的想法应该可以做到: #!/bin/sh while read line; do proto=$(echo $line | cut -f 1 -d :) url=$(echo $line | cut -f 2 -d :) url="${proto}:${url}" tag=$(echo $line | cut -f 3 -d

我需要一个shell脚本,它可以读取包含git存储库url和所需标记的文件,从url克隆存储库并签出列出的标记

示例结构:

等等


有什么想法吗?

像这样的想法应该可以做到:

#!/bin/sh

while read line; do
  proto=$(echo $line | cut -f 1 -d :)
  url=$(echo $line | cut -f 2 -d :)
  url="${proto}:${url}"
  tag=$(echo $line | cut -f 3 -d :)
  repo=$(echo $url | cut -f 4 -d /)
  git clone $url && git --git-dir=$repo/.git checkout $tag
done < $1
#/垃圾箱/垃圾箱
读行时;做
proto=$(echo$行| cut-f 1-d:)
url=$(echo$行| cut-f2-d:)
url=“${proto}:${url}”
tag=$(echo$行| cut-f3-d:)
回购=$(echo$url | cut-f 4-d/)
git clone$url&&git--git dir=$repo/.git checkout$tag
已完成<$1

如果这是你一遍又一遍地做的事情,就像repos更新一样,那么它几乎就是子模块的用例。这个脚本正是我想要的!非常感谢。