0

Hello i reverted a git commit called "Add user microposts".

I didn't mean to do it. I thought revert ment to go back to this version. But it actually means to get undo everything in that commit.

How do i get it back?

You can see what i did below.

enter image description here

Guilherme Franco
  • 1,465
  • 12
  • 19
joeyk16
  • 1,357
  • 22
  • 49
  • http://stackoverflow.com/questions/8728093/how-do-i-un-revert-a-reverted-git-commit – Andrey Deineko Apr 17 '15 at 12:57
  • `git reset --hard 4a593` -- that moves the checked-out branch label to commit 4a593, which here abandons the two reverts. They're still in your repo, if you still want to refer to them add a tag or whatever. – jthill Apr 17 '15 at 14:13

3 Answers3

2

Assuming the commit that you did as a revert is last commit that you have, you can remove that:

git reset --hard HEAD^

It will delete your last commit and will give the changes back.

RAJ
  • 9,697
  • 1
  • 33
  • 63
0

Best way is git cherry-pick 4a593, assuming that's the hash that corresponds to your original commit. This will re-apply the commit on top of your codebase, undoing the revert.

MST
  • 649
  • 6
  • 4
-1

if you want it back, you can revert the revert

git revert <commit>
ilan berci
  • 3,883
  • 1
  • 16
  • 21