[英]Creating a shell script to clone multiple git repositories and checkout a particular tag
I'm in need of a shell script which can read a file containing git repository URLs and the desired tag, clone the repository from the url & checkout the listed tag. 我需要一个shell脚本,该脚本可以读取包含git存储库URL和所需标记的文件,从url复制存储库并签出列出的标记。
Example structure: 示例结构:
http://urlofgitrepohere/project.git:tag-number1 http://urlofgitrepohere/project.git:tag-number1
http://urlofgitrepohere/project.git:tag-number2 http://urlofgitrepohere/project.git:tag-number2
etc. 等等
Any ideas? 有任何想法吗?
Something like this should do the trick: 这样的事情应该可以解决问题:
#!/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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.