That’s when I learned what git reset can really do. Most people think they understand it. Few actually do. The command is simple, but the effects are powerful. Done right, it’s a precision tool. Done wrong, it’s a wrecking ball.
What Git Reset Really Does
At its core, git reset moves your current branch to a different commit. It changes how your working directory, staging area, and commit history line up. Whether it keeps or discards changes depends on the mode you choose:
git reset --soft: Moves HEAD to the target commit but leaves your changes staged.git reset --mixed(default): Moves HEAD and unstages changes, but keeps them in your working directory.git reset --hard: Moves HEAD and wipes all changes from staging and working directory. This is destructive and unrecoverable unless you have backups or reflog.
When to Use Git Reset
Use it to rewrite history in your local branch before pushing. Clean up messy commits. Undo a commit without losing your code. Unstage changes fast. Remove proof of bad experiments. It is not for collaboration unless you know everyone working on that branch is aware of the rewrite.
The Discovery Moment
The real discovery is that git reset isn’t just undo—it’s alignment. It’s the ability to point your branch exactly where it should be. Force it to match your logic, not your mistakes. And doing this means you control the narrative of your codebase, down to the last commit.
Warnings That Matter
Once you push, the story changes. Resets on remote history can break others’ work. Use force pushes sparingly. Always check git log and git status before resetting. Always have a way back—git reflog is often that way.