-2

Consider the following git log:

commit 6c7bd597252a1c9b9fe3ddbac1febbfa62b0f06a
Author: ...
Date:   Sat Oct 15 16:22:16 2016 +0200

    mess2

commit 9c9a8198df44d8efa4ee22c2f877e9fc6a16f27b
Author: ..
Date:   Fri Oct 14 15:52:34 2016 +0200

    mess1

commit 43a07c068d5c8d7879a60450a28c05c980ef34de
Author: ..
Date:   Wed Oct 12 11:52:09 2016 +0200

    v0.6.0

It might be too simple: I'd like to discard mess1 and mess2 and carry on just with commit v0.6.0. How can I do this?

I tried the following: git checkout 43a07c0.. but it seems that the files in my directory are not the ones from the desired commit.

Anton Harald
  • 5,772
  • 4
  • 27
  • 61
  • 4
    Possible duplicate of the second most highly voted question on SO: http://stackoverflow.com/questions/927358/how-to-undo-last-commits-in-git – MD XF Oct 15 '16 at 14:41
  • If in fact *"it seems that the files in my directory are not the ones from the desired commit"* then you are likely mistaken about what was committed in the subsequent messes. Use `git show ` or `git diff ^..HEAD` to ensure you're not discarding something you need. – Jeff Puckett Oct 15 '16 at 15:40

1 Answers1

0

If you don't mind losing mess1 and mess2, you can

git reset --hard 43a07c068d5c8d7879a60450a28c05c980ef34de
Jakub Judas
  • 737
  • 6
  • 16