Git
Discard All Local Changes in the Working Directory
If you want to discard all uncommitted changes (modifications and untracked files) in your working directory:
| |
If you also have untracked files and want to delete them:
| |
-fforces the cleaning.-dremoves untracked directories.
Discard Changes in a Specific File
If you only need to discard changes in a particular file:
| |
Or, in recent versions of Git:
| |
Discard All Changes in Tracked Files
To discard all changes in tracked files without affecting untracked files:
| |
Revert Changes in the Staging Area
If you’ve already added files to the staging area (git add) but haven’t committed yet and want to remove them from there:
| |
Delete the Last Commit
If you’ve made a commit but haven’t pushed it yet:
| |
This undoes the last commit while keeping the changes in your working directory.
If you want to undo the commit and delete the changes from the working directory:
| |