]>
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 | -------- | |
08d22488 | 10 | 'git-rm' [-f] [-n] [-r] [--cached] [--] <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 | |
17 | area (aka index). | |
d4a1cab5 CW |
18 | |
19 | ||
20 | OPTIONS | |
21 | ------- | |
22 | <file>...:: | |
08d22488 JH |
23 | Files to remove. Fileglobs (e.g. `*.c`) can be given to |
24 | remove all matching files. Also a leading directory name | |
25 | (e.g. `dir` to add `dir/file1` and `dir/file2`) can be | |
26 | given to remove all files in the directory, recursively, | |
27 | but this requires `-r` option to be given for safety. | |
d4a1cab5 CW |
28 | |
29 | -f:: | |
08d22488 | 30 | Override the up-to-date check. |
d4a1cab5 CW |
31 | |
32 | -n:: | |
33 | Don't actually remove the file(s), just show if they exist in | |
34 | the index. | |
35 | ||
08d22488 JH |
36 | -r:: |
37 | Allow recursive removal when a leading directory name is | |
38 | given. | |
d4a1cab5 | 39 | |
e994004f | 40 | \--:: |
d4a1cab5 CW |
41 | This option can be used to separate command-line options from |
42 | the list of files, (useful when filenames might be mistaken | |
43 | for command-line options). | |
44 | ||
08d22488 JH |
45 | \--cached:: |
46 | This option can be used to tell the command to remove | |
47 | the paths only from the index, leaving working tree | |
48 | files. | |
49 | ||
d4a1cab5 CW |
50 | |
51 | DISCUSSION | |
52 | ---------- | |
53 | ||
08d22488 JH |
54 | The list of <file> given to the command can be exact pathnames, |
55 | file glob patterns, or leading directory name. The command | |
56 | removes only the paths that is known to git. Giving the name of | |
57 | a file that you have not told git about does not remove that file. | |
d4a1cab5 CW |
58 | |
59 | ||
60 | EXAMPLES | |
61 | -------- | |
62 | git-rm Documentation/\\*.txt:: | |
d4a1cab5 | 63 | Removes all `\*.txt` files from the index that are under the |
a9877f83 | 64 | `Documentation` directory and any of its subdirectories. |
d4a1cab5 CW |
65 | + |
66 | Note that the asterisk `\*` is quoted from the shell in this | |
67 | example; this lets the command include the files from | |
68 | subdirectories of `Documentation/` directory. | |
69 | ||
70 | git-rm -f git-*.sh:: | |
a9877f83 JH |
71 | Remove all git-*.sh scripts that are in the index. |
72 | Because this example lets the shell expand the asterisk | |
73 | (i.e. you are listing the files explicitly), it | |
08d22488 | 74 | does not remove `subdir/git-foo.sh`. |
d4a1cab5 | 75 | |
872d001f JM |
76 | See Also |
77 | -------- | |
78 | gitlink:git-add[1] | |
d4a1cab5 CW |
79 | |
80 | Author | |
81 | ------ | |
82 | Written by Linus Torvalds <torvalds@osdl.org> | |
83 | ||
84 | Documentation | |
85 | -------------- | |
86 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. | |
87 | ||
88 | GIT | |
89 | --- | |
90 | Part of the gitlink:git[7] suite | |
91 |