git filter

编程入门 行业动态 更新时间:2024-10-15 22:28:13
git filter-branch --tree-filter导致'未知版本或路径不在工作树中'(git filter-branch --tree-filter results in 'unknown revision or path not in the working tree')

我的git存储库非常大,我想通过删除一些大文件来减小它的大小,这些大文件是我过去添加的,稍后已经删除,但仍然存在于git历史记录中。 现在我找到了git filter-branch --tree-filter命令。 所以我试过这个:

git filter-branch --tree-filter 'DEL /content/de/files/bigfile.zip' --all

(我在Windows上)。

但是调用这个命令的结果是:

fatal: ambiguous argument '/content/de/files/bigfile.zip'': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'

我不知道该怎么办。 在当前的工作目录中,文件确实不存在。 但是它在历史上还有一些旧的承诺。 我的理解是,该命令会从每次提交中删除文件。

my git repository is quite big and I would like to bring its size down by removing some big files, which I added in the past and already removed later on, but which are still in the git history. Now I found the git filter-branch --tree-filter command. So i tried this:

git filter-branch --tree-filter 'DEL /content/de/files/bigfile.zip' --all

(I'm on Windows).

But the result of invoking this command is:

fatal: ambiguous argument '/content/de/files/bigfile.zip'': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'

I don't know, what to do. In the current working directory, the file is indeed not present. But it is still there in a couple of old commits in the history. My understanding was, that the command would remove the file from every commit.

最满意答案

所以我的版本中的实际错误是,我用引号而不是引号。 看起来像,至少在Windows上,你必须使用这些。

也就是说,jthill的评论和Roberto的回答可能为目前的任务提供更好的解决方案。

So the actual mistake in my version was, that I used single quotes instead of double quotes. Seems like, at least on Windows, you have to use those.

That said, the comments from jthill and the answer from Roberto probably present better solutions to the task at hand.

更多推荐

本文发布于:2023-08-02 03:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1368784.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:git   filter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!