0

In eclipse, I deleted some java files but now I need them back, here is my git log:

commit efc5c0af442a8419eec19997b84c71ebae1b1be4 Author: jack_Git Date: Sun Jan 11 10:17:28 2015 -0800

screwed up

commit 735349994c3150de90b539031644b8e42c03f277 Author: jack_Git Date: Sun Jan 11 10:07:03 2015 -0800

manifest changed

commit cc4c33778e333ea15577c6794e42fc2856d9bee1 Author: jack_Git Date: Sun Jan 11 10:02:34 2015 -0800

merged the asynctask

commit 781a8f41e1168abd3b6e44d17df0f117b78b7a26 Author: jack_Git Date: Sun Jan 11 08:55:28 2015 -0800

I want to roll back to the "manifest changed" commit.

Here is what I have tried:

git revert 735349994c3150de90b539031644b8e42c03f277

But now it states that I am in the middle of a merge!

Hunter Turner
  • 6,804
  • 11
  • 41
  • 56

2 Answers2

1

It seems you are confused by the meaning of git revert. It produces a new commit that reverts (undoes) a particular commit. In your case, it would undo the changes in the "manifest changed" commit. That might be what causes the merge. If you want to undo the "screwed up" commit, you should do git revert efc5c0af44. Or you could do a git reset 735349994c31 which is a bit more brute force and less safe as it changes history.

If you just want particular files back, you could also try git checkout <commit> -- <filename>

For more on git reverting, see this tutorial: https://www.atlassian.com/git/tutorials/undoing-changes/

drRobertz
  • 3,490
  • 1
  • 12
  • 23
0

First make sure your HEAD is clean, before revert.

Second, after revert, some file might include double content from your HEAD & the old commit, you need first git status to see which files have conflict, then open those files, do merge by hand to solve lines like following:

<<<<<<< HEAD
=======
>>>>>>> parent of 97d2375... ...

Instead of use revert, maybe you can git checkout the commit, copy out the deleted files, then back to your HEAD add those files, and commit.

Eric
  • 22,183
  • 20
  • 145
  • 196