LoginSignup
0
0

More than 5 years have passed since last update.

gitのタグを削除するシェル

Posted at

動機

古いタグを削除しようとして、ちまちまやってたけど、面倒になったので、シェルを書くことにする。(シェル考えたほうが遥かに時間かかったんじゃないかというのは内緒)

前段階

https://qiita.com/usamik26/items/7e53bae128bf130b8a32
によればタグを削除するのは↓とのこと。

git tag -d <TAGNAME>
git push origin :<TAGNAME>

実際のシェル

リリースタグを削除するのはちょっと宜しくないと思うのでこんな感じ。
cut使っているのは、tag名から判定のために一部取得したいため。
削除条件の部分は、tagの名称付与によって、かなり異なると思うので、その部分は略。

tagd.sh
#bin/bash

git checkout master
git pull

git tag | grep -vE "RELEASE" | cut <条件色々> | while read line
do
    if [ $line <判定文> <削除条件> ];
    then
        git tag -d `git tag | grep $line`
        git tag | grep $line | awk {'print ":" $1'} | xargs git push origin
    fi
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0