我想从Git存储库中删除所有标记。我该怎么做呢?
使用git tag -d tagname在本地删除标签tagname,并使用git push——tags更新git provider上的标签。
我试着:
git tag -d *
但是我看到*表示当前目录中的文件。
$ git tag -d *
error: tag 'file1' not found.
error: tag 'file2' not found.
...
假设我有很多标签,我想全部删除它们。
我想从Git存储库中删除所有标记。我该怎么做呢?
使用git tag -d tagname在本地删除标签tagname,并使用git push——tags更新git provider上的标签。
我试着:
git tag -d *
但是我看到*表示当前目录中的文件。
$ git tag -d *
error: tag 'file1' not found.
error: tag 'file2' not found.
...
假设我有很多标签,我想全部删除它们。
当前回答
要删除远程标记(在删除本地标记之前),只需执行以下操作:
git tag -l | xargs -n 1 git push --delete origin
然后删除本地副本:
git tag | xargs git tag -d
其他回答
git tag | xargs git tag -d
简单地遵循Unix哲学,即管道处理所有内容。
在Windows上使用相同的命令使用git bash。
并行化和过滤了最新版本
git tag -l "v1.0.*" | xargs -L 1 | xargs git push origin --delete
git fetch origin --prune --prune-tags
第一行,并行地从remote中删除所有匹配的标记。 第二行,从git v2.26.2版本中删除所有已删除的标记,从而更新当前的repo。
为了测试您可以添加的第一行——dry-run,我还鼓励您探索标记列表命令,它有很好的通配符和排除/包含。
要删除远程标记(在删除本地标记之前),只需执行以下操作:
git tag -l | xargs -n 1 git push --delete origin
然后删除本地副本:
git tag | xargs git tag -d
windows用户:
这将通过运行git tag并将该列表提供给git tag -d来删除所有本地标签:
FOR /f "tokens=*" %a in ('git tag') DO git tag -d %a
(网址:https://gist.github.com/RandomArray/fdaa427878952d9768b0)
使用通配符模式删除本地和远程标记的一行代码。
TAGPATTERN = " 0.1。*”;——删除$(git标签-l $TAGPATTERN);git标签-d $(git标签-l $TAGPATTERN)
远程标记首先被删除,因为列表是从本地生成的。