Forrest logo
back to the git tool

git:warp:037e8

Delete newly git-ignored files from your repository
$ git rm -r --cached .
$ git add .
try on your machine

The command git rm -r --cached . is used to remove files or directories from the Git repository's index (also known as the staging area) while keeping them in the working directory.

Here's a breakdown of the command:

  • git rm -r is the command to recursively remove files and directories from the Git index.
  • --cached option is used to remove the files and directories only from the index, while preserving them in the working directory.
  • . refers to the current directory. It indicates that all files and directories within the current directory should be removed from the index.

Following this command, you might want to use git add . to re-add the files and directories that were removed from the index. This command stages all the changes in the current directory to the index, allowing you to include them 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