gpt4 book ai didi

git - 如何从 git push 中删除所有 .pdf 文件

转载 作者:太空狗 更新时间:2023-10-29 14:43:47 25 4
gpt4 key购买 nike

我有一个提交,git diff-tree --no-commit-id --name-only -r fef3ea9ff1ba8d62049fd5f3bc4e2e8a2c08bfd3 输出提交中的所有文件。

文件在不同的文件夹中,很多是.pdf文件

我试试:git rm *.pdf

它说:fatal: pathspec '*.pdf' did not match any files

如何从提交中删除所有 .pdf 文件?

编辑 1

我尝试:git rm -r *.pdf 并给出:

fatal: pathspec '*.pdf' did not match any files

编辑 2

sudo git rm -r */*.pdf

给予

fatal: pathspec 'MyFolder/my_file.pdf' did not match any files

my_file.pdf 是 git diff-tree 输出中列出的第一个文件

最佳答案

删除所有*.pdf你可以做的文件:

git ls-files '*.pdf' | xargs git rm

这假定文件仍然存在。

要更新最顶层的提交,以便它删除文件(除了它更改的任何其他内容),您可以:

git commit --amend

要从最近历史记录中某处的提交中删除文件,请查找 git rebase --interactive并在用 edit 标记要更改的提交后执行上述两个操作在呈现给您的 TODO 列表中。

要从历史深处 stash 的所有提交中删除文件,请查找 git filter-branch .

在所有情况下,关于重写已发布历史的警告均适用。

关于git - 如何从 git push 中删除所有 .pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40879523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com