git clean uncommitted changes code example
Example 1: git revert uncommitted changes
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories.
# '-f' is force, '-d' is remove directories.
git clean -fd
Example 2: git discard local changes
# Discarding local changes (permanently) to a file:
git checkout -- <file>
# Discard all local changes to all files permanently:
git reset --hard
Example 3: how to remove file changes in git
git clean -df
git checkout -- .