【问题标题】:List git tags excluding word in title列出 git 标签,不包括标题中的单词
【发布时间】:2020-11-03 11:30:00
【问题描述】:

我需要删除所有标签,不包括以“AppStore”字样结尾的标签。 我知道我可以用这样的词过滤来删除标签:

git tag -d $(git tag -l "1.158*")

但我不知道如何制作排除模式。 我试过这个:

git tag -l "!*AppStore"

此模式在数字海洋 glob 测试工具中运行良好:shorturl.at/yOR69 但终端没有返回任何内容。

我也试过这个:

git tag -l "!(*AppStore)"

git tag -l "*!(AppStore)"

但结果是一样的。

有人知道如何完成这项任务吗?

【问题讨论】:

  • 为什么不用管子呢?喜欢git tag | grep 'AppStore$' | xargs git tag -d
  • 但这将删除所有包含“AppStore”的标签,不排除...我实际上尝试过这个git tag | grep '^((?!AppStore).)*$' - 它也返回空结果
  • @AlexSh.: grep -P '^((?!AppStore).)*$' ?
  • 好吧,grep -v 'AppStore$'
  • @Inian,它返回usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]] [-e pattern等等

标签: git glob


【解决方案1】:

一口气做很多事情很难 - 分开做小部分并加入它们更容易。尝试首先列出所有标签,然后过滤列表,然后删除标签。

git tag | grep -v 'AppStore$' | xargs git tag -d

【讨论】:

  • 首先要从远程删除标签,我应该制作git tag | grep -v 'AppStore$' | xargs git push -d origin
猜你喜欢
  • 2017-04-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-07
  • 1970-01-01
相关资源
最近更新 更多