Git clean -f -d deleted files from my local directory

git clean -f -d deleted files from my local directory. How can I restore them? I used it to delete unprepared directories and files and found that it also deleted it from the local file system. Is it possible? What have I done wrong, and is there a way to restore them?

+6
source share
3 answers

As the previous answer says, if you are working on Linux, you cannot download them. They are gone: the point is "git clean". If you are not using a file system that can take snapshots, but then you probably know how to get them back.

If your goal was to not see them in git status, you have two options:

A)

git status -uno 

Does not print unused files and directories.

C) If there is a fixed set of files (or a file name template) that you never want to see in git status and do not install them under version control, you can "ignore" them. You just need to put your name or template in a file named ".gitignore" in the root of the repository.

This is commonly used for generated files.

The following example ignores file names ending in ".html" and the file "out / myFile.txt":

 *.html out/myFile.txt 

Cm

 git help ignore 

for more information.

+4
source

Files deleted with git clean were not tracked, which means that git did not save an extra copy. If you need to recover them, it is best to immediately remount the read-only file system and run any deleted file recovery tool suitable for your operating system.

+1
source

It really depends on how you deleted them. On Windows, these files should just go to the trash. On Linux, I suppose git uses the rm command, so you should do a quick search on how to recover files accidentally deleted with rm.

+1
source

Source: https://habr.com/ru/post/945299/


All Articles