Table of Contents
No need to freak out. It happens to everyone at some point I think. Totally normal git experience.
Let’s 🚀
Picking up the pieces
1. Undo the faulty commits
luckily they both have not been pushed and yes, I committed twice before I noticed
git reset --soft HEAD~git reset --soft HEAD~22. Make git stop tracking my changes
git restore --staged .3. Verify that I’ve removed all my commits
git log4. Stash my changes for now
git stash5. Make git forget that I ever made those commits
git rebase6. Get those pesky updates from upstream
git pull7. Back to normal
git stash applyNext time I’ll make sure to checkout into the correct branch before I start commiting. Or maybe I’ll come back to this post again…