Oscar the owl and Vershd logo

How to Git Reset Hard Effortlessly

The Problem

Sometimes you want to obliterate your Git history as though it never happened. Maybe this is one day in the life of a software developer that you'd rather forget.

In this scenario, Mrs Peel has just told you that John's done some changes that make your work redundant. So your last two commits are not needed at all, and the rest of the changes on your local machine just aren't needed.

Using git reset --hard will wipe out the commits you want to delete and the working files that you have. Please think carefully before you use this!

The Solutions

The One Line Fix

This command deletes the last two commits, and all of your working files. For more cautious solutions, look further below.

The Git reset command will copy the last commit hash to a file called .git/ORIG_HEAD if you want to remind yourself of it another time:
git reset --hard HEAD~2
Or use this, which has the identical effect:
git reset --hard e291836

Just Deleting Your Working Files

This command wipes out all your working files and the index, without affecting your commits:
git reset --hard

Keeping a Backup

You can keep a backup in two ways. Firstly you can put a copy of your working files in stash:
git stash
And this command creates a new branch called my-rewind. It doesn't have the latest two commits on the main branch, but is otherwise the same.

So your main branch will continue to have those two commits, until you delete the branch later on. Much safer:
git checkout -b my-rewind HEAD~2

Recovering Deleted Commits

This can get you out of a lot of trouble. It won't replace any working files you've deleted, but this will roll back the last commands that have affected your branches.

It does this by telling the git reflog to go back to its penultimate state, thereby undoing the effect of the previous command you carried out, the reset on the branch.

It's an irony that the undo for a hard reset, is... a hard reset. In fact, this command can undo many actions that you take on a branch. Commits, check outs and cherry picks.

But for now, this will simply undo your branch reset action:
git reset --hard [email protected]{1}
But if you want to save the most time, try a free for any use Git client. It might be the best move you'll ever make with Git.


GitBreeze is an effortless Git GUI that's free for use at work, at home, anywhere. It boosts software development. It works on Windows, macOS, and Linux.

Designed for developers who want Git to be simple, our unique UI/UX boosts your software development - learn more and reap the benefits.

Help & tools

We provide these pages to try to make your programming life easier. Our resources page gives an overview. You can see a full list of our Git tips & tools here.

We have these free tools:

Customers say...

I love any tool that makes my life easier... This is perfect, just the right amount of control. No more, no less. Easy to get started, push and rollback changes... It's a no brainer!
Hayden T.
Oscar the owl and Vershd logo
 ¬© 2023 GitBreeze Ltd.
St. George's flag of England, the Union Jack flag of the United Kingdom, the European Union flag, and the United Nations flag.
chevron-right linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram