
10 Git Commands That Even Senior Developers Google Every Week
You've been using Git for years. You can commit , push , and pull without thinking. But be honest — how often do you still Google "git undo last commit" or "git cherry-pick syntax"? Here are 10 commands that trip up even experienced developers, with the exact syntax you need. 1. Undo the Last Commit (Keep Changes) The situation: You committed too early, typo in the message, or forgot a file. # Undo commit, keep changes staged git reset --soft HEAD~1 # Undo commit, keep changes unstaged git reset --mixed HEAD~1 # Nuclear option: undo commit AND discard changes git reset --hard HEAD~1 Pro tip: --soft is almost always what you want. Your code stays exactly as-is. 2. Interactive Rebase (Clean Up Before PR) The situation: Your branch has 12 commits like "fix typo", "oops", "actually fix it this time". git rebase -i HEAD~5 Your editor opens with options: pick a1b2c3d Add user authentication squash d4e5f6g Fix typo in auth squash h7i8j9k Update auth tests pick l0m1n2o Add rate limiting drop p
Continue reading on Dev.to
Opens in a new tab



