Oscar the owl and Vershd logo

How to Git Reset Effortlessly

The Problem

Although amending a previous commit is can be very simple and only needs you to type git commit --amend, what happens when you have to do more? This is when git reset steps in.

You might have many commits to undo, keeping the existing working files, then you might alter some of those files, and finally make a new commit.

The Solution

In this example, the last three commits you made to fix something are looking quite wrong, and your boss is getting agitated about how swiftly you can release that bug fix. Typical.
This command removes the latest three commits, leaving the working files as they are.
It’s identical to: git reset --mixed HEAD~3. And it will copy the old commit message to a file called .git/ORIG_HEAD which you can use later:
git reset HEAD~3
Or use this, which will wipe out all your existing working files:
git reset --hard HEAD~3
Or use this, which leaves both the index and all your working files unchanged:
git reset --soft HEAD~3
Now edit your files as you wish (the latest commit is currently b2819de):
... Edit as you wish...
This adds, one by one, the specific working files you wish to have in the new commit:
git add where-is/my-pay-rise.txt
Or use this, which adds all of your working files (it’s identical to: git add –a):
git add .
Finally, this creates a new commit and opens a text editor with your original commit message.
Edit it as you wish, close the message, and the commit will be performed:
git commit -c ORIG_HEAD


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
 © 2024 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