2

Not sure there´s a solution to this:

I accidentally staged a directory with:

git add *

then, upon seeing this, I did (major, major mistake, should have of course unstaged)

git rm -r my_directory

To top it all, I followed up with:

git commit -m ¨horrible commit¨

Now the files are nowhere to be found. Is there a way to recover the files?

Thanks

elelias
  • 4,552
  • 5
  • 30
  • 45

1 Answers1

1

If I'm not mistaken, the git rm shouldn't have deleted this directory but complained:

error: the following file has changes staged in the index: my_directory
(use --cached to keep the file, or -f to force removal)

So the directory should still be there...

If you ran it with -f, sorry, then I guess there's nothing you can do.

BartBog
  • 1,889
  • 14
  • 28
  • Ah! indeed, thanks for your message. That indicated me that I had actually committed a previous version with the directory in there, that´s why it did not complain! – elelias Sep 29 '15 at 09:55