1

I wanted to unstage files (as my .gitignore was not set up to ignore some of my IDE files) but in hurry did :

 git add w3

//got some .settings etc folder and files added, in newly added sub folder w3 //the repo here already had sub folders w1 & w2.

Then issued:

 git rm -f w3/*

I'm on windows 8. The files are hard deleted (not in the recycle bin). Any thing I can do with git or any other (free) way?

Edit Add * Also it was opened in STS(eclipse) but now deleted the pom, settings everything. Anyway to restore from within eclipse?

tgkprog
  • 4,493
  • 4
  • 41
  • 70

2 Answers2

3

Un-commited but added files are still in a repository for a while, however it would be quite tricky to restore it especially for a large old repository as usually it has a lot of garbage. So, if you don't mind dig into garbage, start with git fsck and look for dangling blob.

However, seems you cannot restore names of lost files, only content.

kan
  • 28,279
  • 7
  • 71
  • 101
  • its all there. Yes no file names but was just 5 files i changed so i know the names :-) i love git and the linux guys! and stack :-) 5 hours of work. * will add, commit, push more often! – tgkprog Apr 06 '16 at 18:04
  • 1
    @tgkprog 5 hours and no commits? :) That's not the git style! Do commits more often, then amend/rebase/squash/etc before pushing to have prettier history. – kan Apr 06 '16 at 21:08
  • i know. when i get in the zone, food, distractions and apparently good src control get thrown out of the window. will commit more often. and look around for rebase/ squash. tried it once, it errored out. so just left the multiple commits as they were – tgkprog Apr 07 '16 at 17:20
1
  • If the file was not versioned you can't restore it. See the documentation of git-rm. See here for how to undo adding a file to the staging area.

  • If the file was versioned you can retrieve it from a past commit. See this answer for more information.

Of course if you back up your drive you might be able to restore it with your back up program. For that you might get help over at SuperUser.

Community
  • 1
  • 1
vauhochzett
  • 2,732
  • 2
  • 17
  • 40