2011-12-02 18 views
0

我需要一个shell脚本,它可以读取包含git仓库URL和所需标记的文件,从url中复制仓库& checkout列出的标签。创建一个shell脚本来克隆多个git仓库并签出一个特定的标记

实施例结构:

http://urlofgitrepohere/project.git:tag-number1

http://urlofgitrepohere/project.git:tag-number2

任何想法?

+0

如果这是你做一遍又一遍又一遍的东西,作为回购更新,那么它几乎是用例的子模块。 – Cascabel

回答

2

像这样的东西应该做的伎俩:

#!/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 
+0

这个脚本正是我正在寻找的!谢谢 – TEDavis