
Melkor vs Morgoth: The Power of Git Reset
In the vast universe of Git, the reset
command is among the most powerful and dangerous, capable of altering the very history of commits. Just like Melkor, the mightiest of the Ainur, who became Morgoth after his corruption, even a harmless git reset
can turn into something far more devastating.
But fear not: with the right knowledge, you’ll know how to wield this power wisely.
The Power of Git Reset
git reset
allows you to move the pointer of the current branch (HEAD) and, depending on the options used, also affect the index (staging area) and the working directory. It’s a tool that can help you fix mistakes, reorganize your work, or… destroy everything.
Soft Reset: The Melkor of the Ainur
When Melkor was still a spirit of great beauty and power, he had not yet fallen. So is git reset --soft
: powerful, but not destructive.
git reset --soft HEAD~1
Practical example: you just made a commit with the wrong message:
git commit -m "Update"
But you meant to write a more descriptive message. You can use:
git reset --soft HEAD~1
git commit -m "Fix bug in login form validation"
The code remains intact, ready to be recommitted with the correct message.
What changes:
HEAD
moves back by one commit.
The changes from the undone commit are all in the staging area.
You can make a new commit as if nothing happened.

Mixed Reset: The Fall into Darkness
With git reset --mixed
, HEAD is moved back, the staging area is cleared, but the files in the working directory remain unchanged. It’s the default if no option is specified.
git reset --mixed HEAD~1
Practical example: you added files to the staging area by mistake using git add .
, but haven’t committed yet.
git reset
This command clears the staging area so you can calmly choose what to add:
git add login.js
git commit -m "Fix login"
What changes:
HEAD
moves back.
Files are no longer staged.
You can rebuild the commit with only what you need.

Hard Reset: The Destructive Morgoth
The git reset --hard
is the final transformation: like Melkor becoming Morgoth, the destroyer. Everything in the staging area and also in the working directory is lost.
git reset --hard HEAD~1
Practical example: you made local changes that turned out disastrous, and you want to return to the last stable commit.
git reset --hard HEAD
Or, if you made a commit you want to completely undo (including code):
git reset --hard HEAD~1
⚠️ Warning: changes not saved elsewhere will be lost. You can only recover them if git reflog
comes to the rescue.
What changes:
HEAD
, staging area, and working directory are rewritten.
It’s as if the changes never existed.
Powerful and dangerous.

Comparison of the Three Modes
Reset Type | HEAD | Staging area | Working directory |
---|---|---|---|
--soft | Yes | Preserved | Preserved |
--mixed (default) | Yes | Cleared | Preserved |
--hard | Yes | Deleted | Deleted |
Git Reflog: The Secret Way Back
Did you use --hard
and lost an important commit? There’s still hope! Git keeps track of HEAD
movements thanks to reflog
.
git reflog
Find the hash of the commit before the reset, then:
git reset --hard <hash>
Just like the Valar watching from afar, Git also offers a hidden path to salvation.
Conclusion: Power Must Be Mastered

As with the Ainur’s powers, using git reset
requires awareness. It can be a tool of precision or a weapon of mass destruction. Knowing the differences between soft, mixed, and hard reset allows you to control your history masterfully.
Remember: even if you made a mistake, Git often gives you a path to redemption. As with Morgoth, the path to redemption becomes hard only when reflog
is ignored. Be wise, not proud.
“When in doubt, Meriadoc, always follow your reflog.”
…even the smallest reset
can change the course of your repository.