How to rollback two previous commits?

Consider this scenario:

  • Developer A commits : #n
  • Dev. B makes commit # n + 1
  • Dev. A makes commit # n + 2
  • and commit # n + 3

and then discovers that in his commit # n + 2 he introduced a defect.

Like dev. Rollback of the last two commits and will continue to develop when committing # n + 1 ?

Tested git reset --hard HEAD~2 * , but returns to dev A commit #n .

+43
git github reset
Jan 21 '11 at 19:22
source share
1 answer

It should return to fixing n + 1. You probably have a merge too. You can also do git reset --hard <sha1_of_where_you_want_to_be>

ATTENTION!! --hard means that any uncommitted changes that you currently have will be discarded forever.

+75
Jan 21 '11 at 19:48
source share



All Articles