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~2
2. Make git stop tracking my changes
git restore --staged .
3. Verify that I’ve removed all my commits
git log
4. Stash my changes for now
git stash
5. Make git forget that I ever made those commits
git rebase
6. Get those pesky updates from upstream
git pull
7. Back to normal
git stash apply
Next 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…