Updated git_doc to git 1.8
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-rm.xml
blob44ec8773c9bc1f211351c3ff3a196ab887f44a14
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="git-rm(1)">\r
5     <title>git-rm(1)</title>\r
6 <indexterm>\r
7 <primary>git-rm(1)</primary>\r
8 </indexterm>\r
9 <simplesect id="git-rm(1)__name">\r
10 <title>NAME</title>\r
11 <simpara>git-rm - Remove files from the working tree and from the index</simpara>\r
12 </simplesect>\r
13 <simplesect id="git-rm(1)__synopsis">\r
14 <title>SYNOPSIS</title>\r
15 <blockquote>\r
16 <literallayout><emphasis>git rm</emphasis> [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] &lt;file&gt;&#8230;</literallayout>\r
17 </blockquote>\r
18 </simplesect>\r
19 <simplesect id="git-rm(1)__description">\r
20 <title>DESCRIPTION</title>\r
21 <simpara>Remove files from the index, or from the working tree and the index.\r
22 <emphasis>git rm</emphasis> will not remove a file from just your working directory.\r
23 (There is no option to remove a file only from the working tree\r
24 and yet keep it in the index; use <emphasis>/bin/rm</emphasis> if you want to do that.)\r
25 The files being removed have to be identical to the tip of the branch,\r
26 and no updates to their contents can be staged in the index,\r
27 though that default behavior can be overridden with the <emphasis>-f</emphasis> option.\r
28 When <emphasis>--cached</emphasis> is given, the staged content has to\r
29 match either the tip of the branch or the file on disk,\r
30 allowing the file to be removed from just the index.</simpara>\r
31 </simplesect>\r
32 <simplesect id="git-rm(1)__options">\r
33 <title>OPTIONS</title>\r
34 <variablelist>\r
35 <varlistentry>\r
36 <term>\r
37 &lt;file&gt;&#8230;\r
38 </term>\r
39 <listitem>\r
40 <simpara>\r
41         Files to remove.  Fileglobs (e.g. <emphasis>*.c</emphasis>) can be given to\r
42         remove all matching files.  If you want git to expand\r
43         file glob characters, you may need to shell-escape them.\r
44         A leading directory name\r
45         (e.g. <emphasis>dir</emphasis> to remove <emphasis>dir/file1</emphasis> and <emphasis>dir/file2</emphasis>) can be\r
46         given to remove all files in the directory, and recursively\r
47         all sub-directories,\r
48         but this requires the <emphasis>-r</emphasis> option to be explicitly given.\r
49 </simpara>\r
50 </listitem>\r
51 </varlistentry>\r
52 <varlistentry>\r
53 <term>\r
54 -f\r
55 </term>\r
56 <term>\r
57 --force\r
58 </term>\r
59 <listitem>\r
60 <simpara>\r
61         Override the up-to-date check.\r
62 </simpara>\r
63 </listitem>\r
64 </varlistentry>\r
65 <varlistentry>\r
66 <term>\r
67 -n\r
68 </term>\r
69 <term>\r
70 --dry-run\r
71 </term>\r
72 <listitem>\r
73 <simpara>\r
74         Don't actually remove any file(s).  Instead, just show\r
75         if they exist in the index and would otherwise be removed\r
76         by the command.\r
77 </simpara>\r
78 </listitem>\r
79 </varlistentry>\r
80 <varlistentry>\r
81 <term>\r
82 -r\r
83 </term>\r
84 <listitem>\r
85 <simpara>\r
86         Allow recursive removal when a leading directory name is\r
87         given.\r
88 </simpara>\r
89 </listitem>\r
90 </varlistentry>\r
91 <varlistentry>\r
92 <term>\r
93 --\r
94 </term>\r
95 <listitem>\r
96 <simpara>\r
97         This option can be used to separate command-line options from\r
98         the list of files, (useful when filenames might be mistaken\r
99         for command-line options).\r
100 </simpara>\r
101 </listitem>\r
102 </varlistentry>\r
103 <varlistentry>\r
104 <term>\r
105 --cached\r
106 </term>\r
107 <listitem>\r
108 <simpara>\r
109         Use this option to unstage and remove paths only from the index.\r
110         Working tree files, whether modified or not, will be\r
111         left alone.\r
112 </simpara>\r
113 </listitem>\r
114 </varlistentry>\r
115 <varlistentry>\r
116 <term>\r
117 --ignore-unmatch\r
118 </term>\r
119 <listitem>\r
120 <simpara>\r
121         Exit with a zero status even if no files matched.\r
122 </simpara>\r
123 </listitem>\r
124 </varlistentry>\r
125 <varlistentry>\r
126 <term>\r
127 -q\r
128 </term>\r
129 <term>\r
130 --quiet\r
131 </term>\r
132 <listitem>\r
133 <simpara>\r
134         <emphasis>git rm</emphasis> normally outputs one line (in the form of an <emphasis>rm</emphasis> command)\r
135         for each file removed. This option suppresses that output.\r
136 </simpara>\r
137 </listitem>\r
138 </varlistentry>\r
139 </variablelist>\r
140 </simplesect>\r
141 <simplesect id="git-rm(1)__discussion">\r
142 <title>DISCUSSION</title>\r
143 <simpara>The &lt;file&gt; list given to the command can be exact pathnames,\r
144 file glob patterns, or leading directory names.  The command\r
145 removes only the paths that are known to git.  Giving the name of\r
146 a file that you have not told git about does not remove that file.</simpara>\r
147 <simpara>File globbing matches across directory boundaries.  Thus, given\r
148 two directories <emphasis>d</emphasis> and <emphasis>d2</emphasis>, there is a difference between\r
149 using <emphasis>git rm 'd*'</emphasis> and <emphasis>git rm 'd/*'</emphasis>, as the former will\r
150 also remove all of directory <emphasis>d2</emphasis>.</simpara>\r
151 </simplesect>\r
152 <simplesect id="git-rm(1)__removing_files_that_have_disappeared_from_the_filesystem">\r
153 <title>REMOVING FILES THAT HAVE DISAPPEARED FROM THE FILESYSTEM</title>\r
154 <simpara>There is no option for <emphasis>git rm</emphasis> to remove from the index only\r
155 the paths that have disappeared from the filesystem. However,\r
156 depending on the use case, there are several ways that can be\r
157 done.</simpara>\r
158 <section id="git-rm(1)__using_git_commit_a">\r
159 <title>Using git commit -a</title>\r
160 <simpara>If you intend that your next commit should record all modifications\r
161 of tracked files in the working tree and record all removals of\r
162 files that have been removed from the working tree with <emphasis>rm</emphasis>\r
163 (as opposed to <emphasis>git rm</emphasis>), use <emphasis>git commit -a</emphasis>, as it will\r
164 automatically notice and record all removals.  You can also have a\r
165 similar effect without committing by using <emphasis>git add -u</emphasis>.</simpara>\r
166 </section>\r
167 <section id="git-rm(1)__using_git_add_a">\r
168 <title>Using git add -A</title>\r
169 <simpara>When accepting a new code drop for a vendor branch, you probably\r
170 want to record both the removal of paths and additions of new paths\r
171 as well as modifications of existing paths.</simpara>\r
172 <simpara>Typically you would first remove all tracked files from the working\r
173 tree using this command:</simpara>\r
174 <screen>git ls-files -z | xargs -0 rm -f</screen>\r
175 <simpara>and then untar the new code in the working tree. Alternately\r
176 you could <emphasis>rsync</emphasis> the changes into the working tree.</simpara>\r
177 <simpara>After that, the easiest way to record all removals, additions, and\r
178 modifications in the working tree is:</simpara>\r
179 <screen>git add -A</screen>\r
180 <simpara>See <xref linkend="git-add(1)" />.</simpara>\r
181 </section>\r
182 <section id="git-rm(1)__other_ways">\r
183 <title>Other ways</title>\r
184 <simpara>If all you really want to do is to remove from the index the files\r
185 that are no longer present in the working tree (perhaps because\r
186 your working tree is dirty so that you cannot use <emphasis>git commit -a</emphasis>),\r
187 use the following command:</simpara>\r
188 <screen>git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached</screen>\r
189 </section>\r
190 <section id="git-rm(1)__submodules">\r
191 <title>Submodules</title>\r
192 <simpara>Only submodules using a gitfile (which means they were cloned\r
193 with a git version 1.7.8 or newer) will be removed from the work\r
194 tree, as their repository lives inside the .git directory of the\r
195 superproject. If a submodule (or one of those nested inside it)\r
196 still uses a .git directory, <emphasis>git rm</emphasis> will fail - no matter if forced\r
197 or not - to protect the submodule's history.</simpara>\r
198 <simpara>A submodule is considered up-to-date when the HEAD is the same as\r
199 recorded in the index, no tracked files are modified and no untracked\r
200 files that aren't ignored are present in the submodules work tree.\r
201 Ignored files are deemed expendable and won't stop a submodule's work\r
202 tree from being removed.</simpara>\r
203 </section>\r
204 </simplesect>\r
205 <simplesect id="git-rm(1)__examples">\r
206 <title>EXAMPLES</title>\r
207 <variablelist>\r
208 <varlistentry>\r
209 <term>\r
210 <emphasis>git rm Documentation/\*.txt</emphasis>\r
211 </term>\r
212 <listitem>\r
213 <simpara>\r
214         Removes all <emphasis>*.txt</emphasis> files from the index that are under the\r
215         <emphasis>Documentation</emphasis> directory and any of its subdirectories.\r
216 </simpara>\r
217 <simpara>Note that the asterisk <emphasis>*</emphasis> is quoted from the shell in this\r
218 example; this lets git, and not the shell, expand the pathnames\r
219 of files and subdirectories under the <emphasis>Documentation/</emphasis> directory.</simpara>\r
220 </listitem>\r
221 </varlistentry>\r
222 <varlistentry>\r
223 <term>\r
224 <emphasis>git rm -f git-*.sh</emphasis>\r
225 </term>\r
226 <listitem>\r
227 <simpara>\r
228         Because this example lets the shell expand the asterisk\r
229         (i.e. you are listing the files explicitly), it\r
230         does not remove <emphasis>subdir/git-foo.sh</emphasis>.\r
231 </simpara>\r
232 </listitem>\r
233 </varlistentry>\r
234 </variablelist>\r
235 </simplesect>\r
236 <simplesect id="git-rm(1)__see_also">\r
237 <title>SEE ALSO</title>\r
238 <simpara><xref linkend="git-add(1)" /></simpara>\r
239 </simplesect>\r
240 <simplesect id="git-rm(1)__git">\r
241 <title>GIT</title>\r
242 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
243 </simplesect>\r
244 </sect2>\r