git 批量删除 tag

1. master分支存在大量冗余tag

aa0e24dfd920a85c39da400a404309cb6fc69dc0 refs/tags/rc_69
f36f3f21f1ce61db3974e9917f87d3e3219760b7 refs/tags/rc_7
49f6a3a3c16344bb7bc4ed5d45db324ef74ab874 refs/tags/rc_70
4f9c3c28e14f75007affefebfafc9a7f4fe93451 refs/tags/rc_71
6e1b17feb1fba78c203f8ead6d87419714652a14 refs/tags/rc_72
ce5e2a095081ba5455857db4d0e5d3f5c8245d50 refs/tags/rc_73
b3d27b668cafccb78a5943d42dd62e78629ccbe6 refs/tags/rc_74
906756c28ae8b1540e0c48d7e7a36d7304c3f0af refs/tags/rc_75
391cfa6df5fe5dae28a14b033eaea77e8e35fee0 refs/tags/rc_76
2c3f40c58b1a0bd5054e131a4fee320ce3a0ce50 refs/tags/rc_77
a2c7e4a0148ceb4afc551dc866ba01c41f26cec8 refs/tags/rc_78
107a12ca266b09099c07ee55f25325a50ce69f80 refs/tags/rc_79
c8841d52084b32cb474bae0a763e533a6a7d985c refs/tags/rc_8
81e26acf102871b025ebbfc5958ab618909fd41f refs/tags/rc_80
6835d9c2b5a7d6429be3ee94ad873e75e02e20e3 refs/tags/rc_81
8209a60d630024a56923880cf8f6400fafed3fd2 refs/tags/rc_82
dd13b72e07e03232469d88b334aa5f0e8e8bde03 refs/tags/rc_83
970f1f84c8a4d5708fd5da3d201366ed529909c2 refs/tags/rc_84
91be6ae342d66450a0c6cc834d286c22a4fd8816 refs/tags/rc_85
1f41c58fef659b8100e312a9cc3489bbc7395188 refs/tags/rc_86
4c2c115bbf8b0cb7db00febab317a4a79ed37172 refs/tags/rc_87
7ff4cbec0c76d1a8548083a8ed2708df88b1487b refs/tags/rc_88
ae44d04ec5d9af69166359df8ebdb76e60d1b423 refs/tags/rc_89
3544101d56d8955c8162ae43554a0a9201f2fbf2 refs/tags/rc_9
318531f97813dc9777ad000e74a29fabfcb6865f refs/tags/rc_90
36c450a865aadbf1ceb6fbbb76df04d308a8cac8 refs/tags/rc_91
6b06c0bf713bb2d705cdf0f4d8778f46e2e77f2a refs/tags/rc_92
7c365ba7a0b1f92895ec93577e80d47ca2096f56 refs/tags/rc_93
73552a3c535585e2f0ffd450fb093df4a07856bc refs/tags/rc_94
0667bbc0f29075991e1dd9ca47d21d642a89432a refs/tags/rc_97
d0ef0f8408908386868a460a96297c5095919bfe refs/tags/rc_98

2. 一个一个删

本地删除tag :  git  tag -d v1.1

删除远程tag:   git push origin :refs/tags/v1.1

查看本地tag:  git tag -l

查看远程tag:  git show-ref  --tag

很麻烦

3. 批量删

用到awk 正则表达式

批量删本地:  git tag -l| awk '/rc_[0-9]{1}[0-9]{0,}$/ {print  $1}' | xargs git tag -d

批量删远程: git show-ref --tag | awk '/rc_[0-9]{1}[0-9]{0,}$/ {print ":" $2}' | xargs git push origin //这里的空格要注意

查看本地:  git tag -l

查看远程:  git show-ref --tag

这样本地和远程都删除了

上一篇:pxe自动化批量安装系统(Centos7)


下一篇:poj1703Find them, Catch them(并查集以及路径压缩)