How to Hard Reset in Git

A hard reset in Git completely discards all changes in your working directory and staging area, reverting everything to a specific commit state. As the creator of CoreUI with over 25 years of software development experience, I use hard resets carefully when I need to completely abandon current changes and return to a clean state. This operation is destructive and cannot be easily undone, so use it with caution.

Use git reset --hard to completely revert your working directory and staging area to a specific commit.

# Hard reset to the last commit (HEAD)
git reset --hard HEAD

# Hard reset to a specific commit
git reset --hard abc123f

# Hard reset to previous commit
git reset --hard HEAD~1

# Hard reset to 3 commits ago
git reset --hard HEAD~3

# Hard reset to a specific branch state
git reset --hard origin/main

# Check status after hard reset
git status

The git reset --hard command moves the current branch pointer to the specified commit and updates both the staging area and working directory to match that commit exactly. Any uncommitted changes in tracked files are permanently lost. Untracked files are not affected by hard reset. Always ensure you don’t have important uncommitted work before performing a hard reset, or create a backup branch first.

Best Practice Note:

In CoreUI development, we use hard resets primarily for cleaning up experimental branches or when switching between major feature implementations. Always communicate with your team before hard resetting shared branches, and consider using git stash to preserve changes you might need later instead of permanently destroying them.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author