DEV Community

Discussion on: Revert Your Mistaken Git Commits

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!