GIT: Unable to delete file from repo

时间秒杀一切 提交于 2021-02-10 06:57:12

问题


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 ...)

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'

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

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).

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

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.


回答1:


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

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).



来源:https://stackoverflow.com/questions/51822550/git-unable-to-delete-file-from-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!