Search code examples
gitrm

Does git rm remove all history of a file?


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?


Solution

  • 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.