Skip to content

Instantly share code, notes, and snippets.

@citizen428
Created July 9, 2018 04:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save citizen428/e670d90a8bed43e392e1012dd6fd1ad8 to your computer and use it in GitHub Desktop.
Save citizen428/e670d90a8bed43e392e1012dd6fd1ad8 to your computer and use it in GitHub Desktop.
git reset HEAD~2 # undo last two commits, keep changes
git reset --hard HEAD~2 # undo last two commits, discard changes
@O5ten
Copy link

O5ten commented Jul 28, 2018

--hard resets the working tree yes,, but the commit is not permanently lost. git reflog can still save your bottocks in that situation. And if you have the hashes of those commits then you can still easily cherry-pick those commits by hash. :)

@eyadsibai
Copy link

how can u get the hashes that's the question!

@OranShuster
Copy link

OranShuster commented Jul 31, 2018

like @O5ten said, through git reflog
if you do this right after the reset it's very easy to find the lost hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment