Gangmax Blog

自由之思想,独立之精神

How to remove a file completely from git repository history

After I added a huge file into my local git repo and was pushing to remote repo, I got the following error message:

1
> git push origin master
2
Enumerating objects: 34, done.
3
Counting objects: 100% (34/34), done.
4
Delta compression using up to 8 threads
5
Compressing objects: 100% (25/25), done.
6
Writing objects: 100% (25/25), 30.70 MiB | 2.12 MiB/s, done.
7
Total 25 (delta 14), reused 0 (delta 0)
8
remote: Resolving deltas: 100% (14/14), completed with 6 local objects.
9
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
10
remote: error: File daily/perf_test/isolate-0x10268f000-v8.log is 423.56 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB

Then I deleted the file from local repo and tried again. However I still got the same error. After that I realize the problem is: the huge file is in my local git history. I need to remove it from history completely.

From here.

Run the following commands:

1
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch daily/perf_test/isolate-0x10268f000-v8.log" HEAD
2
git push --all

Done.

Comments