GIT批量删除删除远程标签

在代码开发过程中,可能有些标签创建了但不建议使用,批量移除远程仓库上的标签成为一个麻烦的事情,下面提供了在windows平台上批量删除标签的方式。

Windows上的推荐方法

  1. 查看所有远程标签

    git ls-remote --tags origin
  2. 删除除'EXCLUDE_TAG1|EXCLUDE_TAG2|...'之外的所有标签

    git tag -l | Where-Object { $_ -notmatch 'EXCLUDE_TAG1|EXCLUDE_TAG2|...' } | ForEach-Object { git push origin --delete $_ }

    e,g: 删除除’v1.0.1|v1.0.3’以外的所有标签,忽略不存在的标签删除错误

    git tag -l | Where-Object { $_ -notmatch 'v1.0.1|v1.0.3' } | ForEach-Object { git push origin --delete $_ }
  3. 同步本地tag

    git fetch --prune --tags

Linux上的推荐方法

  1. 删除'EXCLUDE_TAG1|EXCLUDE_TAG2|...'以外的所有标签
    git tag -l | grep -vE 'EXCLUDE_TAG1|EXCLUDE_TAG2|...' | xargs -n 1 git push --delete origin

    e,g: 删除除’v1.0.1|v1.0.3’以外的所有标签

    git tag -l | grep -vE 'v1.0.1|v1.0.3' | xargs -n 1 git push --delete origin

如果目标仓库在Github,需要在删除标签的时候同时删除release

  1. 先安装gh cli
  2. 配置gh能正常操作你的仓库
  3. 执行如下命令
    git tag -l | Where-Object { $_ -notmatch 'EXCLUDE_TAG1|EXCLUDE_TAG2|...' } | ForEach-Object { gh release delete $_ --yes; git push origin --delete $_ }
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇