3

I just used a "git clean" command and managed to delete my Documents, Music, and other directories. Is there a way to undo this and somehow get those files back? I did this via Terminal on Mac. Time Machine isn't setup either.

2
  • 2
    No, those files are gone. I hope you have a backup somewhere. Commented Apr 5, 2013 at 17:36
  • possible duplicate of Undoing Git Clean Commented Apr 10, 2013 at 10:54

2 Answers 2

9

I'm afraid those files are gone. git clean is not reversible since those files were not tracked by git.

From the comments it looks like you had your home folder as git repo, but with nothing tracked.

Running git clean -f removed any file inside the home folder (included the one in the subdirectories), leaving only empty subdirectories (the -d option is required for removing them too).

I'm sorry to inform you that you definitely wiped out your whole home directory. Next time you run a git clean use the -n options to perform a dry run and check what's going to happen before it's too late.

Sign up to request clarification or add additional context in comments.

4 Comments

Well when running this command, it said "warning: failed to remove directory name", but in Finder the directory is empty. This matter?
What was the path? What's the git repo?
Nothing was posted to the git repo, and somehow I added an extra ./ to make the path before the desktop
Ok so I will assume that your git repo root is in you home. If that's the case and you weren't tracking anything, that command would remove any file in the home directory. What it won't remove are directories (it requires the -d option), but any file inside them will be removed in any case. Those files are gone, sorry.
1

Unfortunately git clean removes all the untracked files, meaning the files that are deleted are not able to be recovered using git. You might be able to check your trash to see if the files still exist there.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.