【发布时间】: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等等