issue with publishing to github, lack of understanding about the operations, can someone help?

I am getting errors when trying to publish a project. It is fairly large at 2.2gb but it was fine in the last repo i had with the same files. Now when i try to push i get:

Writing objects: 100% (23181/23181), 2.20 GiB | 1.15 MiB/s, done.

Total 23181 (delta 13786), reused 21538 (delta 12389)

fatal: the remote end hung up unexpectedly

I added all of the files into the .gitignore, and in the git ls-files the only file is the .gitignore, but it still tries to push the entire 23,000+ objects and im not sure why. I need help.

I think there is a gap in my understanding because from what I thought I understood and what I have tested would show that only the files in the ls-files are pushed, but that doesn’t seem to be the case. I thought -rm --cashed would prevent the files from being pushed, but all of the files are still trying to be pushed, so I would like to understand where my gap in understanding is, so that I can troubleshoot more effectively and fix this problem as well.

I have googled around and found multiple proclaimed solutions and things to try, which I have tried, non have led me any closer to fixing the issue.

Git is a source control system that retains the history of every change you ever make to your repository. So when you make the change to the .gitignore, that only changes the operation of the repository from that point in time onward. It doesn’t affect anything that’s been stored in the repository beforehand. So if you perform the following operations:

  1. Create a new repo
  2. Make some normal-sized commits
  3. Make a gigantic commit containing a file 500MB in size (above the 100MB limit)
  4. Make some normal-sized commits
  5. Attempt to push the repository to GitHub and get an error

At this point, adding more commits, like changing the .gitignore doesn’t change the fact that the commit created in step 3 still exists. And since git is a write-only database (with certain rare exceptions), there are very few things you can do to change the history of your repository to make it work.

Given that you’re running into problems with a large repository and your username mentions games, you may want to look into Git LFS for handling large assets.

Let us know if you have more questions!