Git 2 reference · 6 entries
Git Undoing Changes
Discard, unstage, reset, revert, stash, recover with reflog, and clean untracked files.
| Name | Description | Since |
|---|---|---|
git restore |
Discard working-tree changes to files, or unstage files, without touching other work. | |
git reset |
Move the current branch to another commit, keeping changes staged (--soft), unstaged (default) or discarding them (--hard). | |
git revert |
Create a new commit that undoes an earlier commit's changes; the safe way to undo commits that were already pushed. | |
git stash |
Save uncommitted changes temporarily, switch tasks, then reapply them with pop or apply. | |
git reflog |
Show where HEAD and branches have pointed recently, so you can recover commits after a reset or bad rebase. | |
git clean |
Remove untracked files from the working tree; always preview with -n first. |