
Fixing a Broken GitHub Repo
Don't Push Enormous Files to GitHub!
Pay close attention to the statement above! A couple of days ago I was working on content for Tama-Toledo Community Visioning and I added a large socialmedia.zip
file to the source repo, and then very stupidly pushed it to GitHub and the repo's main
branch. Naturally, the push didn't finish so I removed the file and pushed a new commit to "remove it permanently". Well, that ain't how git
works!
The "remove" commit appeared to have worked, but now the TTCV site wouldn't deploy since the build time had gone from less than 2 minutes, to more than 10 minutes. I immediately became suspicious of that pesky, large, socialmedia.zip
file, but how could I properly get rid of it?
Using git filter-repo
Fortunately, I found and followed the GitHub docs guidance in Using git filter-repo to remove the troublesome large file, namely socialmedia.zip
, from the repo. The commands I used to do this included...
- brew install git-filter-repo
- git clone https://github.com/Tama-Toledo/community-visioning
The above command was necessary because the next command expects a "clean", recently compressed local repository.
- git filter-repo --invert-paths --path socialmedia.zip
- git remote add origin https://github.com/Tama-Toledo/community-visioning
- git push origin --force --all
- git branch --set-upstream-to=origin/main main
It Worked!
The good news, this worked, and I now have my repo back in shape such that I can successfully deploy it again.
That's a wrap. Oh, in case you want to know what happened to socialmedia.zip
, check out that project's README.md file.