Removing Files That Have Disappeared From The Filesystem 'd/\*\', as the former will also remove all of directory 'd2. Thus, given two directories 'd' and d2, there is a difference between using git rm 'd*' and 'git rm Giving the name of a file that you have not told git about does not remove that file.įile globbing matches across directory boundaries. The command removes only the paths thatĪre known to git. The list given to the command can be exact pathnames, file glob patterns, or leading directory names. Git rm normally outputs one line (in the form of an rm command) for each file removed. Working tree files, whether modified or not, will be left alone.Įxit with a zero status even if no files matched. Use this option to unstage and remove paths only from the index. This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken for command-line options). Instead, just show if they exist in the index and would otherwise be removed by the command.Īllow recursive removal when a leading directory name is given. Sub-directories, but this requires the -r option to be explicitly given.ĭon't actually remove any file(s). dir to remove dir/file1 and dir/file2) can be given to remove all files in the directory, and recursively all If you want git to expand file glob characters, you may need to *.c) can be given to remove all matching files. 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įiles to remove. 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. 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 git rm will not remove a file from just your working directory. Remove files from the index, or from the working tree and the index.