]>
Commit | Line | Data |
---|---|---|
215a7ad1 JH |
1 | git-revert(1) |
2 | ============= | |
7fc9d69f JH |
3 | |
4 | NAME | |
5 | ---- | |
7bd7f280 | 6 | git-revert - Revert an existing commit |
7fc9d69f JH |
7 | |
8 | SYNOPSIS | |
9 | -------- | |
b1889c36 | 10 | 'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit> |
7fc9d69f JH |
11 | |
12 | DESCRIPTION | |
13 | ----------- | |
52a22d1e LAS |
14 | Given one existing commit, revert the change the patch introduces, and record a |
15 | new commit that records it. This requires your working tree to be clean (no | |
16 | modifications from the HEAD commit). | |
7fc9d69f | 17 | |
3a634dcf TC |
18 | Note: 'git revert' is used to record a new commit to reverse the |
19 | effect of an earlier commit (often a faulty one). If you want to | |
20 | throw away all uncommitted changes in your working directory, you | |
21 | should see linkgit:git-reset[1], particularly the '--hard' option. If | |
22 | you want to extract specific files as they were in another commit, you | |
23 | should see linkgit:git-checkout[1], specifically the 'git checkout | |
24 | <commit> -- <filename>' syntax. Take care with these alternatives as | |
25 | both will discard uncommitted changes in your working directory. | |
26 | ||
7fc9d69f JH |
27 | OPTIONS |
28 | ------- | |
52a22d1e LAS |
29 | <commit>:: |
30 | Commit to revert. | |
41a5564e | 31 | For a more complete list of ways to spell commit names, see |
5162e697 | 32 | "SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1]. |
7fc9d69f | 33 | |
3240240f SB |
34 | -e:: |
35 | --edit:: | |
ba020ef5 | 36 | With this option, 'git-revert' will let you edit the commit |
233808db | 37 | message prior to committing the revert. This is the default if |
8bf14d6e PB |
38 | you run the command from a terminal. |
39 | ||
3240240f SB |
40 | -m parent-number:: |
41 | --mainline parent-number:: | |
7791ecbc JH |
42 | Usually you cannot revert a merge because you do not know which |
43 | side of the merge should be considered the mainline. This | |
44 | option specifies the parent number (starting from 1) of | |
45 | the mainline and allows revert to reverse the change | |
46 | relative to the specified parent. | |
b80b5d67 BSSJ |
47 | + |
48 | Reverting a merge commit declares that you will never want the tree changes | |
49 | brought in by the merge. As a result, later merges will only bring in tree | |
50 | changes introduced by commits that are not ancestors of the previously | |
51 | reverted merge. This may or may not be what you want. | |
52 | + | |
53 | See the link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for | |
54 | more details. | |
7791ecbc | 55 | |
8bf14d6e | 56 | --no-edit:: |
ba020ef5 | 57 | With this option, 'git-revert' will not start the commit |
8bf14d6e PB |
58 | message editor. |
59 | ||
3240240f SB |
60 | -n:: |
61 | --no-commit:: | |
de2b82c6 | 62 | Usually the command automatically creates a commit with |
8bd867ee PB |
63 | a commit log message stating which commit was |
64 | reverted. This flag applies the change necessary | |
65 | to revert the named commit to your working tree | |
66 | and the index, but does not make the commit. In addition, | |
67 | when this option is used, your index does not have to match | |
68 | the HEAD commit. The revert is done against the | |
69 | beginning state of your index. | |
df8baa42 JF |
70 | + |
71 | This is useful when reverting more than one commits' | |
8bd867ee | 72 | effect to your index in a row. |
de2b82c6 | 73 | |
3240240f SB |
74 | -s:: |
75 | --signoff:: | |
cfd9c277 DM |
76 | Add Signed-off-by line at the end of the commit message. |
77 | ||
de2b82c6 | 78 | |
7fc9d69f JH |
79 | Author |
80 | ------ | |
59eb68aa | 81 | Written by Junio C Hamano <gitster@pobox.com> |
7fc9d69f JH |
82 | |
83 | Documentation | |
84 | -------------- | |
85 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. | |
86 | ||
87 | GIT | |
88 | --- | |
9e1f0a85 | 89 | Part of the linkgit:git[1] suite |