0

I had a 136mb file in my repo that was in my .gitignore as data.json that was too big to upload to git. The error message I got was:

remote: error: File data.json is 136.60 MB; this exceeds GitHub's file size limit of 100.00 MB

So far I have tried:

  1. git rm --cached data.json
  2. Deleting the file from the remote repo
  3. Copying the file to a new path, deleting it from the old path, and adding the new path to .gitignore as directory/.
  4. git rm data.json, which yields the message: fatal: pathspec 'data.json' did not match any files
  5. git reset HEAD -- just in case it was stuck in some staged change.

As I mentioned, the file is currently in a brand new directory on the local repo, and that directory is also in .gitignore as directory/. This directory does not exist on the remote repo.

When I git add . and git commit -m 'blah', I see the following:

The following paths are ignored by one of your .gitignore files:
file.db
anotherfile.csv
directory
Use -f if you really want to add them.

After I git push, I still get the error.

Why is it still trying to push this file?

snapcrack
  • 1,761
  • 3
  • 20
  • 40
  • Have you done a commit that included the file before? If yes, you'll have to delete the file from previous commits as well. See [this question](https://stackoverflow.com/questions/43762338/how-to-remove-file-from-git-history) to see how to remove files from previous commits. – D Malan Aug 23 '20 at 19:32
  • Super awesome this question was closed because people read the first line and thought I was asking something I wasn't. – snapcrack Aug 23 '20 at 19:47
  • You're free to add more information. What about the question by D Malan? – Nico Haase Oct 05 '20 at 14:18

1 Answers1

-2

You probably instated .gitignore after committing the offending file(s), or did a git add -f offending-file-here and committed the result. Once you told git to track the file, it does dutifully, .gitignore or not.

You can do git rm offending-files and git will start ignoring them. If needed, you could go through the history of the repository with git rebase -i(be careful, you can destroy the repository by mistake when meddling with the history like this, perhaps first do a git checkout -b scratch, fiddle around with the new scratch branch, and rename that one to master once everything is fine) to delete the offending files from history. There are ways to do wholesale rewriting of history, but that truly is for advanced users.

Read the fine manuals and check relevant tutorials before taking the advise of a random dude on the 'net!

vonbrand
  • 11,412
  • 8
  • 32
  • 52
  • Cool thanks man yeah I hadn't already spent hours searching for an answer before asking this :thumbsup: – snapcrack Aug 23 '20 at 19:53