2

Let's say you are going to refactor your code and decide that one of your source files should be deleted, but you may want to retrieve an earlier commit that requires that file. Is there a preferred way to eliminate the file that minimizes the effort to retrieve the old version?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
user1671787
  • 129
  • 9

1 Answers1

0

Just use git rm FILENAME:

NAME

git-rm - Remove files from the working tree and from the index

SYNOPSIS

git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file> …​

DESCRIPTION

Remove files from the index, or from the working tree and the index. 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.) The files being removed have to be identical to the tip of the branch, and no updates to their contents can be staged in the index, though that default behavior can be overridden with the -f option. When --cached is given, the staged content has to match either the tip of the branch or the file on disk, allowing the file to be removed from just the index.

Assem
  • 11,574
  • 5
  • 59
  • 97