Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undoing Git Clean

Tags:

git

So I accidentally removed some new, untracked files from the working tree using git clean -f. Is there a way to undo the clean or re-add those untracked files?

like image 505
Tony Avatar asked Oct 10 '12 15:10

Tony


People also ask

How do I undo a git reset?

So, to undo the reset, run git reset HEAD@{1} (or git reset d27924e ). If, on the other hand, you've run some other commands since then that update HEAD, the commit you want won't be at the top of the list, and you'll need to search through the reflog .

How do I recover files after git clean?

Recovering Deleted Files with the Command Line Git provides ways to recover a deleted file at any point in this life cycle of changes. If you have not staged the deletion yet, simply run `git restore <filename>` and the file will be restored from the index.

Does git clean delete files?

DESCRIPTION. Cleans the working tree by recursively removing files that are not under version control, starting from the current directory. Normally, only files unknown to Git are removed, but if the -x option is specified, ignored files are also removed. This can, for example, be useful to remove all build products.


1 Answers

If your files were cleaned by Git, then they weren't tracked by Git int he first place. Unfortunately you're left with whatever other method you use to restore files from a backup.

This is not something that Git can help you with.

like image 143
Abizern Avatar answered Nov 16 '22 03:11

Abizern