---
title: git rm
---
## git rm
 The git rm command removes, or deletes files from a working git tree and git index. See <a href='https://git-scm.com/docs/git-rm' target='_blank' rel='nofollow'>Git documentation</a> for comprehensive details of the git -rm command.
 The git rm command will remove a file from everywhere within the git tree as there is no option for removing a file from only the working directory. 
 
 ### git rm --cached -r .
 The wildcard "." in place of the filename position in the command <strong>git rm --cached -r .</strong> removes all files from the staging area in a recursive fashion, hence the "-r" option.  The <strong>--cached</strong> option in essence protects working tree files regardless of whether modifications have been applied.
 
 ### git rm -n
 To determine which files would be affected by the git rm command, place the <strong>-n</strong> option in the command.  Executing the command will indicate the files that would be removed had the <strong>-n</strong> option not been present.
 
