2017-05-30 127 views
0

我做了一些svn git迁移。我所有的标签现在看起来都很奇怪:如何通过git标签循环

[email protected] 
[email protected] 
[email protected] 
[email protected] 

但标签是正确的。只有名字是错的。现在我想重命名标签。

所以对每个标记我想做的事:

git tag new old 
git tag -d old 
git push origin :refs/tags/old 
git push --tags 

我想这个脚本。但我已经坚持要找到正确的方式来遍历我的所有标签。

我怎么有循环:for every tag do ......

回答

1

怎么样一个for环路与git tag输出?

for crt_tag in $(git tag) 
do 
    # if you want to suppress @... part 
    git tag ${crt_tag%@*} $crt_tag 
    git tag -d $crt_tag 
    git push origin :refs/tags/$crt_tag 
    git push --tags 
done