DEV Community

How to revert your git commits without panicking

Ben Holmes on June 13, 2019

Step 1: Take deep breaths The best way to overcome your escalating fear that your codebase / world is collapsing around you is deep brea...
Collapse
 
bholmesdev profile image
Ben Holmes

Apologies for the mistakes previously in this article! Made two important fixes:

  • Added a .. to the end of the revert so it would actually revert down to that commit rather than solely that commit. Updated the explanation to reflect that as well.
  • Added a ^ to the git diff command so it would actually log the differences down to and including the copied commit hash. That symbol simply means the ancestor of that commit.
Collapse
 
karlkras profile image
Karl Krasnowsky

Hey Ben, thanks for the article. Something that (hopefully) isn't done too often, but important to get it right when needed.
One thing that confuses me, when performing a rebase, wouldn't you want to rebase to the hash prior to the commit you want to remove?

Collapse
 
bholmesdev profile image
Ben Holmes

Good catch! Correcting that

Collapse
 
mercier_remi profile image
Rémi Mercier

👌My new go-to resource for handling these cases!

And a 💯 for this Dr Who gif!

Collapse
 
niro profile image
Arnau

Great article! What's the terminal them you're using? It's beautiful

Collapse
 
bholmesdev profile image
Ben Holmes • Edited

Thanks so much! I'm using Hyper terminal with Z-shell, Spaceship theme for zsh and hyperpanic for the color scheme.

I probably just threw a ton of things at you you're not familiar with, so I'll just link you to the article that guided me through my setup 😊 medium.com/@caulfieldOwen/youre-mi...

Collapse
 
fultonbrowne profile image
Fulton Browne

I wish I read this a month ago! 😂

Collapse
 
blackdead263 profile image
Adel Bordbari • Edited

we can do glog instead of git log --online