Does git rm remove all history of a file?

Jeffrey picture Jeffrey · Mar 24, 2012 · Viewed 9.6k times · Source

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?

Answer

Daniel Pittman picture Daniel Pittman · Mar 24, 2012

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.