Git init should not delete anything, it creates a new folder called .git
in whatever directory you execute the command from. Now what it shouldn't do doesn't help you much, considering SOMETHING happened, but I'm 99% sure that nothing was actually deleted as the git init
command does not have any calls to delete files. Even if you git init
inside a directory full of files, it just initializes that .git
directory. Now, my one and only guess would be, maybe somehow your desktop's files got put inside that .git
directory (which is a hidden directory by default), and that all your files are there, just hidden. If you are on a Unix system, could you please try a ls -la
while on /Desktop
and see if there is a hidden .git
directory with anything in it. On a Windows system, you can start typing "Show hidden folders" into the start menu and it should give you an option to see all hidden folders (then check same as above, if a hidden .git
folder exists anywhere on/near desktop that contains all your files. git init
should not move anything either, but maybe something went wrong?
Edit:
So here's what went wrong to my best guess...
git init was done in the directory of '~/', this repo 'waifu2x-mac' was cloned/downloaded to desktop. Build.sh was run from a terminal from the location of 'Desktop/waifu2x-mac,
- the first line of the script CDs to the directory of the script
- it then does some stuff to see if there are any untracked files in the current directory (which was location of build.sh)
- because nothing was tracked, as it was a new clone of the repo, it deleted everything in the current directory (/Desktop/waifu2x-mac)
- This included the build.sh file that was currently running, as well as everything involved with that.
- It then tries to CD into /Directories which doesn't exist, which triggers a fail on the script.
- ??? happens and it now considers the git repo located at '~/' the git directory that this script was run from
- The script then executes it's fail condition command, which is git clean -dffx
in essence, this is running rm -rf but just for all untracked files in the current git directory which is everything inside '~/'. the -d specifies all directories, and the 'ffx' is pretty much saying 'force remove everything including anything that is gitignored.' Git clean is unfortunately not undoable, as it doesn't track any changes.
at this point, you have limited options, with no guarantees. Check out this link and try some of the suggestions listed there (like extundelete and the USB recovery tool) Can I undo a `git clean -fdx`?
Best of luck to you- when all this is done, I would definitely go open an issue on that waifu2x-mac's Repo, and link this question in the issue. Even with user error involved, there should never be an issue where a program has autonomy to RECURSIVELY DELETE EVERYTHING unrelated to it, especially on a fail condition. (also why it reverted to the parent git repo and chose that location to delete from is beyond me...)
Also my comment below about git not having any commands to delete files was utterly wrong, and i am well aware of that.