GIT:无法从存储库中删除文件

问题描述:

当前,我们被迫将存储库从Gitlab迁移到Github.当我们想用"git push -u origin master"将仓库推送到Github时.不幸的是,这导致以下错误(复制的输出1):

Currently, we are forced to migrate our repository from Gitlab to Github. When we want to push our repo to Github with "git push -u origin master". Unfortunately, this results in the following errors (Copied Output 1):

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

remote: error: File Data/Setup/Database.2.7.0.1.accdb is 426.50 MB; this exceeds GitHub Enterprise's file size limit of 200.00 MB

remote: error: File Data/DPM/Database 2.4.0.0.accdb is 422.12 MB; this exceeds GitHub Enterprise's file size limit of 200.00 MB

remote: error: File Data/Setup/Database 2.5.0.1.accdb is 422.00 MB; this exceeds GitHub Enterprise's file size limit of 200.00 MB

remote: error: File Data/Setup/Database 2.6.0.0.accdb is 421.98 MB; this exceeds GitHub Enterprise's file size limit of 200.00 MB

(and more ...)

删除文件是不够的,因为它包含在以前的提交中.我们尝试了以下建议的修复: https://medium.com/@mrkdsgn/fixing-the-gh001-large-files-detected-you-may-want-to-try-git-large-file-storage-43336b983272 .我们尝试使用以下命令从整个存储库中删除所有访问数据库:

It's insufficient to remove the file, because it is included in previous commits. We tried the following fix suggested in: https://medium.com/@mrkdsgn/fixing-the-gh001-large-files-detected-you-may-want-to-try-git-large-file-storage-43336b983272 . We tried to remove all the accessdatabases from our entire repo using the following command:

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Data/\*accdb'

输出如下(复制的输出2):

The output is as following (Copied Output 2):

(starting from 1/1398...)
Rewrite 9f3d64449f73d663bfa3c657b7a9406bb153d040 (1394/1398) (2452 seconds passed, remaining 7 predicted)    rm 'Data/Setup/Database.2.7.0.1.accdb'
Rewrite 8804497bd5d2db157deb3f169764bd230fbd5379 (1395/1398) (2454 seconds passed, remaining 5 predicted)    rm 'Data/Setup/Database.2.7.0.1.accdb'
Rewrite de9e3cc72501c056696b7e327e5c957016f69247 (1396/1398) (2456 seconds passed, remaining 3 predicted)    rm 'Data/Setup/Database.2.7.0.1.accdb'
Rewrite c6cb5be434b7ad7a132a383995add34fe6176506 (1397/1398) (2457 seconds passed, remaining 1 predicted)    rm 'Data/Setup/Database.2.7.0.1.accdb'
Rewrite 01f39409430cd15a638c99f788a8acce69b9de0b (1398/1398) (2459 seconds passed, remaining 0 predicted)    rm 'Data/Setup/DPM Database.2.7.0.1.accdb'

Ref 'refs/heads/Branch_Jack' was rewritten

似乎我们删除了出现在超出Github限制"错误中的所有扩展名为.accdb的文件.但是不幸的是,当我们再次执行"git push -u origin master"时,我们收到与(复制输出1)中相同的错误.

It looks like we removed all files with .accdb extensions that appeared in the "exceed Github limit" error. But unfortunately, when we execute "git push -u origin master" again, we receive the same errors as in (Copied Output 1).

有人建议我们做错了什么吗?我们如何删除仓库中的acces数据库?

Does anyone have suggestions what we did wrong? How can we delete the accesdatabases in our repo?

PS.我们尝试了如下所述的方法 https://git-scm.com/book/zh-CN/v2/Git-Internals-Maintenance-and-Data-Recovery 也位于移除对象"下.现在,垃圾收集和git prune -expire的附加步骤无法解决问题.

PS. We tried the method as described in https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery under "removing object" as well. The additional steps of garbage collect and git prune -expire now did not solve the problem.

我猜最可能的问题是您是否没有过滤 master 的全部历史记录.您给出的 filter-branch 命令只会过滤当前 HEAD 的历史记录.如果您只想推送大师,您可以说

I guess the most likely problem is if you aren't filtering the entire history of master. The filter-branch command you gave will only filter the history of the current HEAD. If you're only going to push master, you could say

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Data/\*accdb' -- master

或者,如果您想从整个回购历史记录中删除文件,可以说

Or, if you want to remove the file from the entire repo history, you could say

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Data/\*accdb' -- --all

请记住,在运行另一个 filter-branch 命令之前,必须删除 original/引用(如果尚未引用).(这些引用也会阻止尝试使用 gc 清理本地存储库,但是我怀疑这确实是一个问题.发送到服务器的包应该仅包含可访问的对象...我不知道文档可以保证这种行为,但是我认为我从未观察过.)

Keep in mind that before running another filter-branch command, you'll have to remove the original/ refs (if you haven't already). (These refs would also thwart attempts to clean up the local repo with gc, but I doubt that's really an issue. The pack sent to the server should only contain reachable objects... I don't know that the docs guarantee this behavior, but I don't think I've ever observed otherwise.)

如果仍然不能解决问题,我们可能需要更多信息.确保错误消息仍然完全相同(例如,不仅是相同的一般错误,而且可能涉及其他对象/路径).

If that still doesn't fix it, we may need more information. Make sure the error message is still exactly the same (not just the same general error, but maybe referring to other objects/paths, for example).