]>
Commit | Line | Data |
---|---|---|
d4a1cab5 CW |
1 | git-rm(1) |
2 | ========= | |
3 | ||
4 | NAME | |
5 | ---- | |
7bd7f280 | 6 | git-rm - Remove files from the working tree and from the index |
d4a1cab5 CW |
7 | |
8 | SYNOPSIS | |
9 | -------- | |
bb1faf0d | 10 | 'git-rm' [-f] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>... |
d4a1cab5 CW |
11 | |
12 | DESCRIPTION | |
13 | ----------- | |
08d22488 JH |
14 | Remove files from the working tree and from the index. The |
15 | files have to be identical to the tip of the branch, and no | |
16 | updates to its contents must have been placed in the staging | |
bdecd9d4 MM |
17 | area (aka index). When --cached is given, the staged content has to |
18 | match either the tip of the branch *or* the file on disk. | |
d4a1cab5 CW |
19 | |
20 | ||
21 | OPTIONS | |
22 | ------- | |
23 | <file>...:: | |
08d22488 JH |
24 | Files to remove. Fileglobs (e.g. `*.c`) can be given to |
25 | remove all matching files. Also a leading directory name | |
26 | (e.g. `dir` to add `dir/file1` and `dir/file2`) can be | |
27 | given to remove all files in the directory, recursively, | |
28 | but this requires `-r` option to be given for safety. | |
d4a1cab5 CW |
29 | |
30 | -f:: | |
08d22488 | 31 | Override the up-to-date check. |
d4a1cab5 | 32 | |
e0e6c096 | 33 | -n, \--dry-run:: |
d4a1cab5 CW |
34 | Don't actually remove the file(s), just show if they exist in |
35 | the index. | |
36 | ||
08d22488 JH |
37 | -r:: |
38 | Allow recursive removal when a leading directory name is | |
39 | given. | |
d4a1cab5 | 40 | |
e994004f | 41 | \--:: |
d4a1cab5 CW |
42 | This option can be used to separate command-line options from |
43 | the list of files, (useful when filenames might be mistaken | |
44 | for command-line options). | |
45 | ||
08d22488 JH |
46 | \--cached:: |
47 | This option can be used to tell the command to remove | |
48 | the paths only from the index, leaving working tree | |
49 | files. | |
50 | ||
bb1faf0d SG |
51 | \--ignore-unmatch:: |
52 | Exit with a zero status even if no files matched. | |
53 | ||
e0e6c096 | 54 | -q, \--quiet:: |
b48caa20 SG |
55 | git-rm normally outputs one line (in the form of an "rm" command) |
56 | for each file removed. This option suppresses that output. | |
57 | ||
d4a1cab5 CW |
58 | |
59 | DISCUSSION | |
60 | ---------- | |
61 | ||
08d22488 JH |
62 | The list of <file> given to the command can be exact pathnames, |
63 | file glob patterns, or leading directory name. The command | |
64 | removes only the paths that is known to git. Giving the name of | |
65 | a file that you have not told git about does not remove that file. | |
d4a1cab5 CW |
66 | |
67 | ||
68 | EXAMPLES | |
69 | -------- | |
70 | git-rm Documentation/\\*.txt:: | |
d4a1cab5 | 71 | Removes all `\*.txt` files from the index that are under the |
a9877f83 | 72 | `Documentation` directory and any of its subdirectories. |
d4a1cab5 CW |
73 | + |
74 | Note that the asterisk `\*` is quoted from the shell in this | |
75 | example; this lets the command include the files from | |
76 | subdirectories of `Documentation/` directory. | |
77 | ||
78 | git-rm -f git-*.sh:: | |
a9877f83 JH |
79 | Remove all git-*.sh scripts that are in the index. |
80 | Because this example lets the shell expand the asterisk | |
81 | (i.e. you are listing the files explicitly), it | |
08d22488 | 82 | does not remove `subdir/git-foo.sh`. |
d4a1cab5 | 83 | |
872d001f JM |
84 | See Also |
85 | -------- | |
5162e697 | 86 | linkgit:git-add[1] |
d4a1cab5 CW |
87 | |
88 | Author | |
89 | ------ | |
90 | Written by Linus Torvalds <torvalds@osdl.org> | |
91 | ||
92 | Documentation | |
93 | -------------- | |
94 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. | |
95 | ||
96 | GIT | |
97 | --- | |
5162e697 | 98 | Part of the linkgit:git[7] suite |