0

A while ago I accidentally added some large data files to a git repo folder on my desktop without putting the file names in the .gitignore file. Since then I made lots of changes to the files in my git repository on my desktop without pushing them to origin. Now I finally want to sync my local branch and the main branch, but I cannot.

My solution to this was to go to my github branch on the github website and then manually delete every file from origin so that I could cleanly push everything. I added the data file names into my .gitignore file, but I cannot push anything. It tries to send gigabytes of data and then eventually crashes.

As a test, I put every file name on my desktop into the .gitignore file then tried to push. In theory this would sync an empty repository with another empty repository so there should be no file transferring or reading and writing. However, git push still tries to transfer hundreds of megabytes of information to the main repository. Here is a snapshot of what I mean:

jbryaniv@Js-MacBook-Air-3 Past % git push -f
Enumerating objects: 1078, done.
Counting objects: 100% (1048/1048), done.
Delta compression using up to 8 threads
Compressing objects: 100% (995/995), done.
Writing objects:  55% (558/1010), 765.57 MiB | 1.37 MiB/s   

What is causing this massive slowdown to my git writing process even though there are no files to write?

Shep Bryan
  • 567
  • 5
  • 13
  • 2
    If you added a large file, then your best bet would be to use https://rtyley.github.io/bfg-repo-cleaner/ or git filter to remove said file completely from history. Otherwise, the file is still there and git may still send it (after determining if the peer [remote] have the file). – NoDataFound Aug 16 '22 at 20:31
  • 1
    I think the same as @NoDataFound, your files has been added previously to the localrepository and git will push them while it will be in your git history. As said before you can use bfg-repo-cleaner to clean it all and use [Git LFS](https://git-lfs.github.com/) if you wanna push large binaries. – Dylan Tavares Aug 16 '22 at 20:38
  • @NoDataFound and @DylanTavares That totally worked. I ran `` git filter-branch --index-filter \ 'git rm -rf --cached --ignore-unmatch .' HEAD`` and now everything is fine. – Shep Bryan Aug 16 '22 at 20:50

0 Answers0