Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does git rm remove all history of a file?

Tags:

My project has a file foo that I've been using and checking in with git. I just did some refactoring so that I no longer need the file at all. If I do git rm foo, will the file still exist in older commits? Will I be able to check out an older commit and work with the file?

like image 928
Jeffrey Avatar asked Mar 24 '12 02:03

Jeffrey


People also ask

What does git rm do?

The primary function of git rm is to remove tracked files from the Git index. Additionally, git rm can be used to remove files from both the staging index and the working directory. There is no option to remove a file from only the working directory.

Does git save history?

Git stores the complete history of your files for a project in a special directory (a.k.a. a folder) called a repository, or repo.

Can you delete git commit history?

In order to do so, run : rm -rf . *git command which will delete any file ending with .


1 Answers

No, git rm (plus the commit) writes a new tree that reflects the file is no longer present. The entire history of the file, including creation, modifications, and eventual deletion, is present in the history.

like image 168
Daniel Pittman Avatar answered Sep 18 '22 20:09

Daniel Pittman