4. Undo & Recovery

6 cards

Review this deck
All cards in this deck

`git restore <file>`

discard changes in the working directory (unstaged)

`git restore --staged <file>`

unstage a file (keep the changes)

`git reset HEAD~1`

undo the last commit, keep the changes **unstaged** (default = `--mixed`)

`git revert <hash>`

create a new commit that reverses an old one (safe for shared branches)

`git reflog`

show HEAD history, find "lost" commits

`git stash`

temporarily save uncommitted changes

4. Undo & Recovery – Flashcards – Git | Học Dev