0

I have been having problems with pulling from git to my server for a few days with it saying one file was untracked, after reading github i ran git clean -d -f and its basically removed a whole ton of stuff, is there a way to undo this? im really stuck at the moment i had a couple of people from another country contribute to the project and since then everything's just got into a whole mess.

enter image description here

phd
  • 82,685
  • 13
  • 120
  • 165
Gaz Smith
  • 1,100
  • 1
  • 16
  • 30
  • 2
    Unfortunately you cannot undo git lean, there is no restore – Milenko Jevremovic Apr 26 '19 at 18:02
  • 4
    `git clean` removes, by definition, files that *aren't* stored in Git (or more precisely, in the current commit, but that's probably close enough to "any commit" for your case). That means any undoing has to be outside Git as well: e.g., on a Mac you might use your Time Machine backups. – torek Apr 26 '19 at 18:02
  • 2
    If those files aren't tracked by Git, how'd they get on your machine in the first place? – Vlad274 Apr 26 '19 at 18:04
  • Recycle bin in Windows? – Alexan Apr 26 '19 at 18:04
  • its on the server, so its lost all the public files – Gaz Smith Apr 26 '19 at 18:05
  • try to undelete your files with additional software that scans and recovers erased files, e.g. https://www.easeus.com/ad/recover-deleted-files.htm?gclid=Cj0KCQjw2IrmBRCJARIsAJZDdxD_Rp8eadwa3rIAJoMSrjHxd65nH-4EYPAs2j-9eizKGplc73IOLHYaAiK7EALw_wcB – Theo Itzaris Apr 26 '19 at 18:07
  • 1
    Possible duplicate of [Can I restore deleted files (undo a \`git clean -fdx\`)?](https://stackoverflow.com/questions/6267180/can-i-restore-deleted-files-undo-a-git-clean-fdx) – phd Apr 26 '19 at 18:26
  • https://stackoverflow.com/search?q=%5Bgit-clean%5D+undo – phd Apr 26 '19 at 18:26
  • Why did you run git clean? What issue were you facing? – evolutionxbox Apr 26 '19 at 21:13

2 Answers2

2

Some IDEs like IntelliJ and Eclipse allow you to recover files from a local history. If you happen to be using one of those IDEs, you could try out this feature.

1

No. Git can't undo a git clean.

Those files were deleted and never tracked by git. Git won't help you since it never knew about those files in the first place. You have to recover those files from the block device directly, or use an other mechanism.

Also I would suggest that you re-mount the device on which the repository was stored read-only now. (sudo mount -o remount,ro /path/to/mountpoint). With every write operation to that device, your chances of a successful recovery become slimmer and slimmer.

Ente
  • 2,301
  • 1
  • 16
  • 34