2

Is there any way to redo changes in the working directory after checking them out? I just ssh'd into a server I hadn't been on in a while and saw that there were unstaged changes in the index. I assumed that this was just scratch work I had done last time, but figured because I didn't commit them they weren't important and ran:

$ git checkout .

to give myself a clean slate. Unfortunately this was a bit hasty, because it turns out that last time I was on this server I just forgot to commit, and the majority of the work I had done was in those changes.

I feel like this is a long shot, but is there any way to bring back these local changes to the working directory?

akowalz
  • 359
  • 3
  • 16
  • 7
    Short answer: no. – Oliver Charlesworth Sep 27 '14 at 21:32
  • 1
    If Git was made aware of those changes through any means (stashing unstaged, added to staging), then there's a *chance*. Otherwise, you may be out of luck. – Makoto Sep 27 '14 at 21:33
  • 2
    For future reference, it is often safest to use `git stash` to restore a "clean slate". You can also use `git diff` to see the changes before running `git checkout` or `git reset`. – Code-Apprentice Sep 27 '14 at 21:34
  • Ok, thanks. I figured not. I'll know to watch out for this in the future! – akowalz Sep 27 '14 at 21:35
  • 1
    You can't have "unstaged changes in the index". By definition, anything in the index is staged. Staged changes you can recover. Unstaged changes are gone. – Andrew C Sep 27 '14 at 21:59

1 Answers1

1

Either those changes were:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250