Git never loses a commit — it only loses your nerve. Every guide below was written from a real recovery: what each flag does to history, the working tree and the reflog, and when a force push is a tool versus a confession.
In a hurry, right now? git undo generator → the exact command for your case
- Git Undo Last Commit: Keep Changes, Stay Safe Git undo last commit the safe way: keep the changes with reset --soft, unstage with --mixed, or fix a pushed commit with revert — exact commands for each.
- Git Revert vs Reset: Which One Saves Your History? Git revert vs reset explained: which command undoes commits safely, when reset --hard destroys work, and how each rewrites shared GitHub history.
- Git Cherry Pick: Multiple Commits, Branches, Conflicts Git cherry-pick explained: copy a commit from another branch, pick multiple commits or a range, fix conflicts, and know when merge or rebase fits better.
- git stash a Single File Without Losing the Rest Stash one file while the rest of your work-in-progress stays put: git stash push -- <path>, the interactive -p flow, and the three ways to get changes back.
- Git Sync Fork With Upstream: 3 Safe Methods git sync fork with upstream three ways: the two-command pull, a rebase for clean history, GitHub's sync button — plus fixes when your fork won't sync.
- Git Remove Untracked Files: Safe git clean Guide Git remove untracked files safely with git clean: dry-run first, -fd for directories, -x for ignored files — plus why git clean isn't removing anything.