在git中,我怎样才能有效地删除所有匹配模式的refs? [英] In git, how can I efficiently delete all refs matching a pattern?

查看:400
本文介绍了在git中,我怎样才能有效地删除所有匹配模式的refs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着时间的推移,我在 refs / builds / archived / * 中归档了一堆构建标记,现在我想删除它们以恢复一些空间并减少总体对象数(超过5万个带注释的git标签存储在那里)。

看来唯一的方法就是这样:

  git show-ref \ 
| awk'/ refs \ / builds \ / archived \ / [^ \ /] * $ / {printgit update-ref -d$ 2}'\
| sh

这非常慢。此外,这样做似乎会减缓从repo完成的所有git提取,直到我运行 git gc 就可以了。

解决方案

你应该可以说一些类似于

  git for-each- ref --format ='删除%(refname)'refs / builds / archived | git update-ref --stdin 

这应该在一次批量操作中完成整个过程。请注意,我自己并没有真正尝试过。


I have over time archived a bunch of build tags in refs/builds/archived/* and I now want to delete them to recover some space and reduce total object count (over 50k annotated git tags are stored there).

It would appear that the only way to do this is like so:

git show-ref\
 | awk '/refs\/builds\/archived\/[^\/]*$/ { print "git update-ref -d "$2}'\
 | sh

This is extremely slow. Also, doing this appears to slow down any git fetches done from the repo until I get to run git gc on it.

解决方案

You should be able to say something like

git for-each-ref --format='delete %(refname)' refs/builds/archived | git update-ref --stdin

This should do the whole thing in one bulk operation. Note that I haven't actually tried this myself.

这篇关于在git中,我怎样才能有效地删除所有匹配模式的refs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆