undo changes in git
Throw away changes not committed yet, unstage files, or put work aside for later.
version-control
danger Steps marked danger delete, overwrite or stop something. Read each one before you run it.
steps
-
git statuswhat changed, staged or not
-
git restore file.txtdanger throw away one file's changes
-
git restore --staged file.txtdanger unstage it, keeping the changes
-
git stashput every change aside; git stash pop brings them back
-
git clean -ndlist the new files git does not track
-
git clean -fddanger delete them
-
git reset --harddanger throw away every change to tracked files
notes
- restore, clean -fd and reset --hard cannot be undone for changes never committed.
commands used
git
Each has a page in lore: lore git opens it.