]>
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 | ----------- | |
25dc7200 JL |
14 | Remove files from the index, or from the working tree and the index. |
15 | `git rm` will not remove a file from just your working directory. | |
16 | (There is no option to remove a file only from the work tree | |
17 | and yet keep it in the index; use `/bin/rm` if you want to do that.) | |
18 | The files being removed have to be identical to the tip of the branch, | |
19 | and no updates to their contents can be staged in the index, | |
20 | though that default behavior can be overridden with the `-f` option. | |
21 | When '--cached' is given, the staged content has to | |
22 | match either the tip of the branch or the file on disk, | |
23 | allowing the file to be removed from just the index. | |
d4a1cab5 CW |
24 | |
25 | ||
26 | OPTIONS | |
27 | ------- | |
28 | <file>...:: | |
08d22488 | 29 | Files to remove. Fileglobs (e.g. `*.c`) can be given to |
25dc7200 JL |
30 | remove all matching files. If you want git to expand |
31 | file glob characters, you may need to shell-escape them. | |
32 | A leading directory name | |
33 | (e.g. `dir` to remove `dir/file1` and `dir/file2`) can be | |
34 | given to remove all files in the directory, and recursively | |
35 | all sub-directories, | |
36 | but this requires the `-r` option to be explicitly given. | |
d4a1cab5 CW |
37 | |
38 | -f:: | |
08d22488 | 39 | Override the up-to-date check. |
d4a1cab5 | 40 | |
e0e6c096 | 41 | -n, \--dry-run:: |
25dc7200 JL |
42 | Don't actually remove any file(s). Instead, just show |
43 | if they exist in the index and would otherwise be removed | |
44 | by the command. | |
d4a1cab5 | 45 | |
08d22488 JH |
46 | -r:: |
47 | Allow recursive removal when a leading directory name is | |
48 | given. | |
d4a1cab5 | 49 | |
e994004f | 50 | \--:: |
d4a1cab5 CW |
51 | This option can be used to separate command-line options from |
52 | the list of files, (useful when filenames might be mistaken | |
53 | for command-line options). | |
54 | ||
08d22488 | 55 | \--cached:: |
25dc7200 JL |
56 | Use this option to unstage and remove paths only from the index. |
57 | Working tree files, whether modified or not, will be | |
58 | left alone. | |
08d22488 | 59 | |
bb1faf0d SG |
60 | \--ignore-unmatch:: |
61 | Exit with a zero status even if no files matched. | |
62 | ||
e0e6c096 | 63 | -q, \--quiet:: |
b48caa20 SG |
64 | git-rm normally outputs one line (in the form of an "rm" command) |
65 | for each file removed. This option suppresses that output. | |
66 | ||
d4a1cab5 CW |
67 | |
68 | DISCUSSION | |
69 | ---------- | |
70 | ||
25dc7200 JL |
71 | The <file> list given to the command can be exact pathnames, |
72 | file glob patterns, or leading directory names. The command | |
73 | removes only the paths that are known to git. Giving the name of | |
08d22488 | 74 | a file that you have not told git about does not remove that file. |
d4a1cab5 | 75 | |
25dc7200 JL |
76 | File globbing matches across directory boundaries. Thus, given |
77 | two directories `d` and `d2`, there is a difference between | |
78 | using `git rm \'d\*\'` and `git rm \'d/\*\'`, as the former will | |
79 | also remove all of directory `d2`. | |
d4a1cab5 CW |
80 | |
81 | EXAMPLES | |
82 | -------- | |
83 | git-rm Documentation/\\*.txt:: | |
d4a1cab5 | 84 | Removes all `\*.txt` files from the index that are under the |
a9877f83 | 85 | `Documentation` directory and any of its subdirectories. |
d4a1cab5 CW |
86 | + |
87 | Note that the asterisk `\*` is quoted from the shell in this | |
25dc7200 JL |
88 | example; this lets git, and not the shell, expand the pathnames |
89 | of files and subdirectories under the `Documentation/` directory. | |
d4a1cab5 CW |
90 | |
91 | git-rm -f git-*.sh:: | |
a9877f83 JH |
92 | Because this example lets the shell expand the asterisk |
93 | (i.e. you are listing the files explicitly), it | |
08d22488 | 94 | does not remove `subdir/git-foo.sh`. |
d4a1cab5 | 95 | |
56ae8df5 | 96 | SEE ALSO |
872d001f | 97 | -------- |
5162e697 | 98 | linkgit:git-add[1] |
d4a1cab5 CW |
99 | |
100 | Author | |
101 | ------ | |
102 | Written by Linus Torvalds <torvalds@osdl.org> | |
103 | ||
104 | Documentation | |
105 | -------------- | |
106 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. | |
107 | ||
108 | GIT | |
109 | --- | |
9e1f0a85 | 110 | Part of the linkgit:git[1] suite |