schrobe
schrobe

Reputation: 837

How to reset to the state before a given git commit?

I have a big repository with some-hundred commits.

Given is the hash to a specific commit deep in down the history where something was fixed. I know that I can revert to that commit by using

git reset 56e05fced214c44a37759efa2dfc25a65d8ae98d

However, I want the state BEFORE that fix was applied, i.e. one commit earlier.

(Now, in SVN I would just revert to the previous revision number but I know with GIT and all its distributed character that's not so easy).

How can I do this?

Upvotes: 1

Views: 1508

Answers (1)

Schleis
Schleis

Reputation: 43760

You should be able to do git reset 56e05fced214c44a37759efa2dfc25a65d8ae98d^

The ^ selects the commit previous. You can also go any number of commits by using ~. For two commits, it would be git reset 56e05f~2

Upvotes: 5

Related Questions