从特定路径中删除文件名? [英] remove filenames from specific path?

查看:102
本文介绍了从特定路径中删除文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用BFG Repo-Cleaner工具,目的是通过从目录层次结构的多个位置删除(临时/大型)文件来清理git repo的历史记录...

I've been playing around with the BFG Repo-Cleaner tool in order to clean up the history of a git repo by removing (temporary / large) files from several places in the directory hierarcy...

即 /root/test/a.txt /root/test2/a.txt

i.e. /root/test/a.txt /root/test2/a.txt

现在,我想删除"test/a.txt"的所有"" 引用,但保留/test2/a.txt的版本..

Now i'd like to remove all references of the 'test/a.txt' but keep the /test2/a.txt version..

有什么方法可以使用BFG彻底删除它吗? (如 https://help.github.com/articles/remove-sensitive-data 所述)

Is there any way to cleanly remove that using BFG? (as mentioned on https://help.github.com/articles/remove-sensitive-data)

由于回购记录已有相当长的历史(提交了1万次),因此BFG实际上比我迄今所见的其他方法快[emot ...

Since the repo has a fairly large history ( 10K commits ) BFG really is alot faster than the other methods i've seen so far...

推荐答案

我是 BFG的开发者,很高兴您发现它有用且快速.使BFG如此之快的特殊方式之一是它与路径无关-因此您不能直接说出--delete /root/test/a.txt之类的字眼.我正在考虑为基于路径的操作添加一些支持,但是我不希望它对性能产生不利影响.

I'm the developer of The BFG, and I'm glad you've been finding it useful and fast. Part of the special-sauce that makes the BFG so fast is that it's path-independent - so you can't say directly say something like --delete /root/test/a.txt. Adding some support for path-dependent action is something I'm thinking about, but I don't want it to adversely affect performance.

清理回购协议时的关键问题是:在以下两种选择中,您要实现什么目标?

The key question when cleaning your repo is: What are you trying to achieve, out of these two options:

  • 减少Git存储库大小
  • 删除私人数据

从您的问题看来,您的唯一目标是减少Git存储库大小的第一个目标.如果/root/test/a.txt很小(即与存储库中其他合法文件的大小相当),则不能真正使用--strip-blobs-bigger-than X来删除它,因为它会删除太多其他常规文件.但是,如果是这样的话,我就放松一下,放手-与您的整个回购相比,这不会花费您太多的存储空间.

From your question, it sounds like your only aim is the first one, to reduce Git repository size. If /root/test/a.txt is fairly small- ie comparable in size to the rest of the legitimate files in your repository - you can't really use --strip-blobs-bigger-than X to get rid of it, as it would remove too many of your other regular files. But if that is the case, I would just relax, and let it go - it's not costing you much storage space compared to the entirety of your repo.

如果/root/test/a.txt足够大,足以打扰您,您可以使用--strip-blobs-bigger-than X摆脱它-请记住,BFG保护当前提交中的所有文件(如果使用--protect-blobs-from <refs>,甚至可以保护更多分支) )-这样,您正在当前正在使用的合法大文件将不会受到影响.

If /root/test/a.txt is big enough to bother you, you can probably just use --strip-blobs-bigger-than X to get rid of it - remember that The BFG protects all files in your current commit (or even more branches if you use --protect-blobs-from <refs>) - so legitimate big files that you're currently using won't get touched.

如果您真的想要摆脱这个可怜的无害文件,但是 想要过滤大小,则有两个BFG支持的选项:

If you really want to get rid of this poor innocuous file, but don't want to filter on size, there are two BFG-supported options:

...这将删除整个文件夹/root/test/(以及所有其他名为"test"的文件夹),但不会删除/root/test2/.如果要保留/root/test/中的其他内容,则用处不大.

...which will delete the entire folder /root/test/ (and all other folders called 'test'), but not /root/test2/. Not much use if there are other things in /root/test/ that you want to keep.

...您必须查找/root/test/a.txt曾经用过的所有Git blob-id,您可以使用一些git命令来完成此操作:

...you have to look up all the Git blob-ids there have ever been for /root/test/a.txt, which you can do with a some git commands like this:

git log --format=%H -- /root/test/a.txt | xargs -IcommitId git rev-parse commitId:/root/test/a.txt

这篇关于从特定路径中删除文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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