Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git clean -f -d removed files from my local directory

Tags:

git

git-clean

git clean -f -d removed files from my local directory as well How do I retreive them? I used it to remove untracked directories and files and found that it also deleted it from my local file system. Is this possible? What did i do wrong and is there a way to retreive them?

like image 767
tan Avatar asked May 17 '13 20:05

tan


People also ask

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.

Does git clean remove ignored files?

The git clean command also allows removing ignored files and directories.

Does git rm remove local file?

git rm will not remove a file from just your working directory. (There is no option to remove a file only from the working tree and yet keep it in the index; use /bin/rm if you want to do that.)


1 Answers

As a previous answer says, if you're working on Linux, you can't retrieve them. They're gone: that's the point of "git clean". Unless you're using a filesystem capable on doing snapshots but then, you would probably know how to get them back.

If your goal was to avoid seeing them in "git status", you have two possibilities:

A)

git status -uno

does not print untracked files and directories.

B) If there are a fixed set of files (or a filename pattern) that you will never want to see in "git status" nor put them under versioning, you can "ignore" them. You simply have to put their name or pattern in a file named ".gitignore" at your repository's root.

This is typically used for generated files.

The following example ignores filenames ending with ".html" and the file called "out/myFile.txt":

*.html
out/myFile.txt

See

git help ignore

for more info.

like image 140
deubeuliou Avatar answered Nov 28 '22 23:11

deubeuliou