Revert Git to last commit
If you want to revert everything back to the last commit and discard all local changes, use this ๐
๐ฅ Hard reset (most common & safest)
This restores your working tree and index to the latest commit.
What this does
-
❌ Discards all modified files
-
❌ Discards all staged files
-
❌ Discards all untracked changes in tracked files
-
✅ Leaves your repo exactly as the last commit
๐งน Also remove untracked files (optional but often needed)
If you also want to delete untracked files and folders:
Or preview first (recommended):
✅ One-liner (full nuclear option)
⚠️ Important warning
This is irreversible unless:
-
Changes were committed
-
Or stashed
-
Or still exist elsewhere
Total page views:
Comments
Post a Comment