0

For example, I did a checkout to a previous version such as 894e8b4e93d8f3. Then I make some revise in this previous version and commit the change but not push due to a detached HEAD error. Next, I did another checkout so the code changed to another version and the previous revision seemed to have lost. How can I find the previous committed code? Is the committed code still in local repository?

torek
  • 448,244
  • 59
  • 642
  • 775
Steve Xu
  • 13
  • 3
  • You can do `git revert`. – Spencer Wieczorek Jun 25 '17 at 16:04
  • Do you want to erase the commit from your history? Or simply get the state of file(s) prior to that commit back – Peter Reid Jun 25 '17 at 16:10
  • Do you see the commit in `git log --all --graph`? – choroba Jun 25 '17 at 16:10
  • I'd inspect `HEAD`'s reflog (by running `git reflog`) and attempt to identify the commit of interest by its commit message. Once you've found it, you can check it out using its hash. – jub0bs Jun 25 '17 at 16:13
  • 1
    I'm going to use https://stackoverflow.com/q/4845505/1256452 as the duplicate here, since it's the same entry into the problem, even though that posting is itself marked a duplicate. – torek Jun 25 '17 at 16:14

0 Answers0