Today I thought I’d have a smooth coding day, but instead, I spent hours wrestling with Git and GitHub 😅.
After fixing my secret-handling yesterday, I tried to push my project again and ran into new challenges.
The Problems
Old commits still had my token: Even though I removed it locally, it was still in the history. GitHub push protection wasn’t letting me push until it was completely gone.
Git history cleanup: I had to use git filter-repo to actually remove the file from all previous commits. That felt scary because it rewrites history.
Two project folders: To stay safe, I worked in a cloned folder called chef-ai-clean. But then I had both chef-ai and chef-ai-clean on my computer and kept confusing which one was the “real” project.
Remote issues: I deleted the old repo on GitHub and created a new one. That meant I had to re-add the remote and figure out why my first push was failing.
What I Learned
git filter-repo is the right way to clean secrets from history (not just deleting the line).
Fresh clones are safer when rewriting history.
Renaming folders is fine — I just moved the old one aside and renamed chef-ai-clean back to chef-ai.
The first push needs:
git push -u origin main
The -u is important because it sets the tracking branch, so afterwards I can just run git push.
The Win
After a lot of trial and error, I finally have:
A clean repo on GitHub
Secrets safely ignored by Git
A local folder with the right name (chef-ai)
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)