我正在尝试以下命令:
$ git push --set-upstream origin patch-cleanfiles
Enumerating objects: 336, done.
Counting objects: 100% (336/336), done.
Delta compression using up to 4 threads
Compressing objects: 100% (326/326), done.
Writing objects: 100% (336/336), 280.48 MiB | 613.00 KiB/s, done.
Total 336 (delta 146), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (146/146), done.
remote: error: Trace: 843cbb54d34aef5ff3a234efb921f178f5b03980de1c05808c14f12bdf6470c0
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File doc/Initial Call/Thomas,Isaias, Joe- -overview.mp4 is 262.90 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/RaptorX/Paragrafen.app.git
! [remote rejected] patch-cleanfiles -> patch-cleanfiles (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/RaptorX/Paragrafen.app.git'
有趣的是,我的项目中没有名为“doc”的文件夹,因此整个文件不存在并且尝试将其从工作树中删除根本不起作用:
$ git rm -r --cached doc/*
fatal: pathspec 'doc/*' did not match any files
$ git rm -r --cached doc/*.mp4
fatal: pathspec 'doc/*.mp4' did not match any files
$ git rm -r --cached doc/Initial\ Call/*.mp4
fatal: pathspec 'doc/Initial Call/*.mp4' did not match any files
$ git rm -r --cached doc/Initial\ Call/*
fatal: pathspec 'doc/Initial Call/*' did not match any files
$ git rm -rf --cached *.mp4
fatal: pathspec '*.mp4' did not match any files
这是 git 目前正在跟踪的内容:
$ git ls-tree --full-tree --name-only -r HEAD
.gitignore
.gitmodules
License.txt
README.md
Sample Texts/Demo.docx
Sample Texts/Really long sample 2.docx
Sample Texts/Sample.txt
Sample Texts/Sample_A_1_before.docx
Sample Texts/Sample_A_2_after.docx
src/Paragrafen-App.ahk
src/lib/ActiveScript.ahk
src/lib/ScriptObject
src/lib/gui/badge.ahk
src/lib/law_linker.js
src/res/Logo.png
src/res/Splash.png
src/res/app.ico
关于如何开始解决这个特定问题,有什么指示吗?
答案1
找到了问题的解决方案。
即使该文件不在索引中,但有提交的历史记录,而这正是尝试推送它时出现的问题。
阅读完这些说明后这里我能够用这个命令修复它:
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch ./doc/*.mp4' --tag-name-filter cat -- --all
请注意,filter-branch 命令有点复杂,可能会产生其他问题。
运行该命令后,我能够从数据库中删除所有不需要的文件,但保留提交历史记录(据我所知)。