1

I erroneously committed a big file (>100Mb) that I really didn't have to include in my git history.

I removed the file, also, I removed it from git cache, then I committed again.

Despite this, when I try to push to my remote branch, git gives me a size error.

I also tried a git rebase, but the commit is still there, what shall I do?

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 195471c5940ef60fa1dd2ba5a52a4a6a
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File custom_include/xyz.sql is 964.43 MB; this exceeds GitHub's file size limit of 100.00 MB
4
  • Can you please add the specific error message and/or the specific git commands that you ran to uncover this issue? Commented Apr 21, 2017 at 16:01
  • Would this help: help.github.com/articles/…? Even though it is about sensitive data, it is about permanently removing data from the git repo. Commented Apr 21, 2017 at 16:04
  • no, it's not about sensitive info, it's just that the big file prevent the commit to be pushed Commented Apr 21, 2017 at 16:04
  • Note that the same concept applies. You need to remove entirely the big file from your commit history. The steps to do so are the exact same as completely removing sensitive data from the history. Commented Apr 21, 2017 at 17:20

2 Answers 2

3

Once you have committed the large file, deleting it and committing that change will not remove it from the history.

As long as you know the full path where the file was located you can use the command below to remove the file from the commit history.

However, please be aware: this command will re-write your git history from the point at which the file you are removing was added.

git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch [path to file to remove]' --prune-empty --tag-name-filter cat -- --all

I learnt how to do this from this excellent blog post by Ted Naleid: http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history

Sign up to request clarification or add additional context in comments.

2 Comments

It's a bad practice to post links without technical details, since there is a chance that website will be closed in a near future.
I was expanding on my answer as you were commenting :).
1

If you used a git revert or removed the file and committed, that's not enough because the file will be part of the history of the branch you are trying to push anyway. You could get rid of the file on the revision where you added it by amending it (which will create a fork) and then cherry-pick all the changes that were applied on the original branch after the revision you amend.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.