<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-rm(1)">
<articleinfo>
    <title>git-rm(1)</title>
        <indexterm>
                <primary>git-rm(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-rm - Remove files from the working tree and from the index</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara><emphasis>git rm</emphasis> [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] &lt;file&gt;&#8230;</simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Remove files from the index, or from the working tree and the index.
<emphasis>git-rm</emphasis> will not remove a file from just your working directory.
(There is no option to remove a file only from the work tree
and yet keep it in the index; use <literal>/bin/rm</literal> 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 <literal>-f</literal> option.
When <emphasis>--cached</emphasis> 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.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
&lt;file&gt;&#8230;
</term>
<listitem>
<simpara>
        Files to remove.  Fileglobs (e.g. <literal>*.c</literal>) can be given to
        remove all matching files.  If you want git to expand
        file glob characters, you may need to shell-escape them.
        A leading directory name
        (e.g. <literal>dir</literal> to remove <literal>dir/file1</literal> and <literal>dir/file2</literal>) can be
        given to remove all files in the directory, and recursively
        all sub-directories,
        but this requires the <literal>-r</literal> option to be explicitly given.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-f
</term>
<term>
--force
</term>
<listitem>
<simpara>
        Override the up-to-date check.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-n
</term>
<term>
--dry-run
</term>
<listitem>
<simpara>
        Don&#8217;t actually remove any file(s).  Instead, just show
        if they exist in the index and would otherwise be removed
        by the command.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-r
</term>
<listitem>
<simpara>
        Allow recursive removal when a leading directory name is
        given.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--
</term>
<listitem>
<simpara>
        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).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--cached
</term>
<listitem>
<simpara>
        Use this option to unstage and remove paths only from the index.
        Working tree files, whether modified or not, will be
        left alone.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--ignore-unmatch
</term>
<listitem>
<simpara>
        Exit with a zero status even if no files matched.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-q
</term>
<term>
--quiet
</term>
<listitem>
<simpara>
        <emphasis>git-rm</emphasis> normally outputs one line (in the form of an "rm" command)
        for each file removed. This option suppresses that output.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_discussion">
<title>DISCUSSION</title>
<simpara>The &lt;file&gt; list given to the command can be exact pathnames,
file glob patterns, or leading directory names.  The command
removes only the paths that are known to git.  Giving the name of
a file that you have not told git about does not remove that file.</simpara>
<simpara>File globbing matches across directory boundaries.  Thus, given
two directories &#8216;d` and <literal>d2</literal>, there is a difference between
using <literal>git rm 'd*&#8217;</literal> and &#8216;git rm 'd/\*\&#8217;<literal>, as the former will
also remove all of directory `d2</literal>.</simpara>
</simplesect>
<simplesect id="_examples">
<title>EXAMPLES</title>
<variablelist>
<varlistentry>
<term>
git rm Documentation/\\*.txt
</term>
<listitem>
<simpara>
        Removes all <literal>\*.txt</literal> files from the index that are under the
        <literal>Documentation</literal> directory and any of its subdirectories.
</simpara>
<simpara>Note that the asterisk <literal>\*</literal> is quoted from the shell in this
example; this lets git, and not the shell, expand the pathnames
of files and subdirectories under the <literal>Documentation/</literal> directory.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git rm -f git-*.sh
</term>
<listitem>
<simpara>
        Because this example lets the shell expand the asterisk
        (i.e. you are listing the files explicitly), it
        does not remove <literal>subdir/git-foo.sh</literal>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_see_also">
<title>SEE ALSO</title>
<simpara><xref linkend="git-add(1)"/></simpara>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
