DEV Community

Cover image for Revert Your Mistaken Git Commits

Revert Your Mistaken Git Commits

Michael D. Callaghan on May 01, 2019

Recently one of my development teams had a merge problem. For version control, they use a modified form of GitFlow, and it was time to merge from ...
Collapse
 
stephencweiss profile image
Stephen Charles Weiss

Returning to the topic of "first bad commit" / oldest / highest number -- highest number actually doesn't clarify it for me.

If we use the git log that you referenced as a basis for the example, and we wanted to revert the last five commits, would it be:

git revert --no-edit 111b003..852291a

following the pattern:

git revert --no-edit <oldest-commit-hash>..<newest-commit-hash>

1   852291a   blah blah blah
2   f575c87   blah blah
3   83d855d   blah blah
4   9fa11df   blah blah blah blah
5   111b003   blah blah
6   2b3a530   blah blah blah
7   a4c5f54   blah blah blah blah blah blah
8   b2a62fa   blah blah blah blah blah blah blah blah blah
9   5fb67b9   blah blah blah
10  4d1a5fc   blah blah blah
11  ed40aec   Initial commit

Thanks!

Collapse
 
jay97 profile image
Jamal Al

Wow this is funny.

Collapse
 
walkingriver profile image
Michael D. Callaghan

Thanks, I think? :)

Collapse
 
stephencweiss profile image
Stephen Charles Weiss

FYI- the SO link is dead here and on your blog -- not sure if there was a specific conversation you were pointing to.

Collapse
 
walkingriver profile image
Michael D. Callaghan

I am not sure how it ended up being a link. I think I was simply saying I searched on SO, and was not intending to point to any specific conversation. Thanks for pointing it out.