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
2
3
4
5
6
7
8
9
10
> git push origin master
Enumerating objects: 34, done.
Counting objects: 100% (34/34), done.
Delta compression using up to 8 threads
Compressing objects: 100% (25/25), done.
Writing objects: 100% (25/25), 30.70 MiB | 2.12 MiB/s, done.
Total 25 (delta 14), reused 0 (delta 0)
remote: Resolving deltas: 100% (14/14), completed with 6 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
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
2
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch daily/perf_test/isolate-0x10268f000-v8.log" HEAD
git push --all

Done.

Comments