Forrest logo
back to the git tool

git-rm:tldr:877eb

git-rm: Remove file from repository index but keep it untouched locally.
$ git rm --cached ${filename}
try on your machine

The command "git rm --cached ${filename}" is used with Git, which is a distributed version control system. It is used to remove a file from the Git index or staging area without deleting it from the file system.

Explanation of the command parts:

  • "git rm" is the command used to remove files from the Git repository. By default, it will remove the file from both the repository and the working directory.
  • "--cached" is an option that specifies that the file should be removed only from the index or staging area without deleting it from the file system.
  • "${filename}" is the placeholder for the name of the file you want to remove from the index.

When you run the command "git rm --cached ${filename}", Git will remove the specified file from the Git index, but it will remain in your working directory. This means that the file will still exist in your file system, but it will no longer be tracked by Git. The removal of the file from the index indicates that it should not be included in the next commit.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool