Last active
February 20, 2021 22:38
-
-
Save khoa-le/03c4de439125f969e03d to your computer and use it in GitHub Desktop.
Git undo all uncommitted changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This will unstage all files you might have staged with git add: | |
git reset | |
This will revert all local uncommitted changes (should be executed in repo root): | |
git checkout . | |
You can also revert uncommitted changes only to particular file or directory: | |
git checkout [some_dir|file.txt] | |
Yet another way to revert all uncommitted changes (longer to type, but works from any subdirectory): | |
git reset --hard HEAD | |
This will remove all local untracked files, so only git tracked files remain: | |
git clean -fdx | |
WARNING: -x will also remove all ignored files! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment