1

I have not found any solution for this besides people saying no way. I am just hoping that someone knows a new trick that could do this.

So here is what I did.

git commit -m "test configure finished"

git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)


git push origin master


git revert HEAD
error: Your local changes to the following files would be overwritten by merge:


git reset --hard fb305ae7d5e01e595986
a3753cbdd22ead4cb945
HEAD is now at fb305ae

I did not perform a git add before these commands.

Can I get those unstaged files back???

phd
  • 82,685
  • 13
  • 120
  • 165
EzyHoo
  • 301
  • 2
  • 14
  • 8
    Not using Git, no. That's why all the other answers say "no". – torek Oct 31 '19 at 01:56
  • 2
    git reset --hard checks out the files from the specified commit and overrides the ones in the work tree. So, if you did modify and not commit them, the changes are lost to the mercy of the underlying file system and tools. you might be able to restore previous versions on ntfs or from a snapshot on linux, or from a backup file from a debugger, but not from git. – Serge Oct 31 '19 at 02:10
  • @Serge Thank you, I was able to get 2 files back from debugger!!! Better than nothing! – EzyHoo Oct 31 '19 at 04:51
  • 1
    Related git feature: `git reflog`, its usage to 'redo after undo loca' is explained here: https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/#redo-after-undo-local – Mehdi Oct 31 '19 at 10:48
  • @Mehdi I was able to check them out by doing reflog, but since I did not perform git add, the files that I commit to git is not staged. – EzyHoo Oct 31 '19 at 18:36
  • I was able to get them back by the IntelliJ local history feature. Thank you all – EzyHoo Oct 31 '19 at 19:35

0 Answers0