带有 --invert-paths 标志的 Git filter-repo 不起作用

问题描述 投票:0回答:2

我尝试从 Git 历史记录中删除文件。

我正在使用git filter-repo,其github存储库是https://github.com/newren/git-filter-repo,但我遇到了一些麻烦。

正如这里的例子所说,
https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#EXAMPLES\
https://marcofranssen.nl/remove-files-from-git-history-using-git-filter-repo/

我已尝试使用这些命令来删除带有

--force
标志的 .pyc 文件:

sudo git filter-repo --path-glob '*/*.pyc' --invert-paths
sudo git filter-repo --path-glob '*.pyc' --invert-paths
sudo git filter-repo --path *.pyc --invert-paths

但是没有任何效果。

命令的输出看起来不错,但是当我检查 .pyc 文件时,它们仍然存在。

输出:

Parsed 28 commits
New history written in 0.46 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
HEAD is now at 1bc0b68 Re-add templates directory
Enumerating objects: 1084, done.
Counting objects: 100% (1084/1084), done.
Delta compression using up to 2 threads
Compressing objects: 100% (267/267), done.
Writing objects: 100% (1084/1084), done.
Total 1084 (delta 784), reused 1084 (delta 784), pack-reused 0
Completely finished after 1.33 seconds.

看起来一切都很顺利,但文件并没有在 git 上删除。文件被完美保存,没有任何变化。

问题有解决办法吗?

git git-filter-repo
2个回答
1
投票

我的错误是走错了路。我使用了“C:\RepoDir\DirectoryToBeRemoved”(注意反斜杠),但应该只使用“DirectoryToBeRemoved/”


0
投票

不知道原因,但问题已解决。但还是不知道为什么会这样。

当我尝试上面的命令时,一切似乎都很顺利,但文件没有被删除。

它们没有从工作树中删除,甚至提交或索引(阶段)也没有变化。
这意味着当我尝试时

git diff
git diff HEAD
git diff --cached HEAD

未检测到任何变化。

但是当我再次推送分支并将其克隆到其他目录中时,
*.pyc 文件似乎已被删除。

我不知道原因,但似乎提交历史已更改,但它不会影响本地工作树,并且

git diff
没有捕获更改。

如果我发现一些东西,我会更多地检查并更新这个答案。


补充:

git status
也没有将*.pyc文件显示为未跟踪已修改


我可能会找到重点。
这是一个愚蠢的问题。

由于

git status

git add
.gitignore
没有显示任何内容。感谢并抱歉所有花费时间解决此问题的人。

我不会删除这个问题,即使这是一个愚蠢的问题,对于谁可能会和我犯同样的错误。

© www.soinside.com 2019 - 2024. All rights reserved.