1git-revert(1) 2============= 3 4NAME 5---- 6git-revert - Revert some existing commits 7 8SYNOPSIS 9-------- 10[verse] 11'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>... 12'git revert' (--continue | --skip | --abort | --quit) 13 14DESCRIPTION 15----------- 16 17Given one or more existing commits, revert the changes that the 18related patches introduce, and record some new commits that record 19them. This requires your working tree to be clean (no modifications 20from the HEAD commit). 21 22Note: 'git revert' is used to record some new commits to reverse the 23effect of some earlier commits (often only a faulty one). If you want to 24throw away all uncommitted changes in your working directory, you 25should see linkgit:git-reset[1], particularly the `--hard` option. If 26you want to extract specific files as they were in another commit, you 27should see linkgit:git-checkout[1], specifically the `git checkout 28<commit> -- <filename>` syntax. Take care with these alternatives as 29both will discard uncommitted changes in your working directory. 30 31OPTIONS 32------- 33<commit>...:: 34 Commits to revert. 35 For a more complete list of ways to spell commit names, see 36 linkgit:gitrevisions[7]. 37 Sets of commits can also be given but no traversal is done by 38 default, see linkgit:git-rev-list[1] and its `--no-walk` 39 option. 40 41-e:: 42--edit:: 43 With this option, 'git revert' will let you edit the commit 44 message prior to committing the revert. This is the default if 45 you run the command from a terminal. 46 47-m parent-number:: 48--mainline parent-number:: 49 Usually you cannot revert a merge because you do not know which 50 side of the merge should be considered the mainline. This 51 option specifies the parent number (starting from 1) of 52 the mainline and allows revert to reverse the change 53 relative to the specified parent. 54+ 55Reverting a merge commit declares that you will never want the tree changes 56brought in by the merge. As a result, later merges will only bring in tree 57changes introduced by commits that are not ancestors of the previously 58reverted merge. This may or may not be what you want. 59+ 60See the link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for 61more details. 62 63--no-edit:: 64 With this option, 'git revert' will not start the commit 65 message editor. 66 67--cleanup=<mode>:: 68 This option determines how the commit message will be cleaned up before 69 being passed on to the commit machinery. See linkgit:git-commit[1] for more 70 details. In particular, if the '<mode>' is given a value of `scissors`, 71 scissors will be appended to `MERGE_MSG` before being passed on in the case 72 of a conflict. 73 74-n:: 75--no-commit:: 76 Usually the command automatically creates some commits with 77 commit log messages stating which commits were 78 reverted. This flag applies the changes necessary 79 to revert the named commits to your working tree 80 and the index, but does not make the commits. In addition, 81 when this option is used, your index does not have to match 82 the HEAD commit. The revert is done against the 83 beginning state of your index. 84+ 85This is useful when reverting more than one commits' 86effect to your index in a row. 87 88-S[<keyid>]:: 89--gpg-sign[=<keyid>]:: 90 GPG-sign commits. The `keyid` argument is optional and 91 defaults to the committer identity; if specified, it must be 92 stuck to the option without a space. 93 94-s:: 95--signoff:: 96 Add Signed-off-by line at the end of the commit message. 97 See the signoff option in linkgit:git-commit[1] for more information. 98 99--strategy=<strategy>:: 100 Use the given merge strategy. Should only be used once. 101 See the MERGE STRATEGIES section in linkgit:git-merge[1] 102 for details. 103 104-X<option>:: 105--strategy-option=<option>:: 106 Pass the merge strategy-specific option through to the 107 merge strategy. See linkgit:git-merge[1] for details. 108 109--rerere-autoupdate:: 110--no-rerere-autoupdate:: 111 Allow the rerere mechanism to update the index with the 112 result of auto-conflict resolution if possible. 113 114SEQUENCER SUBCOMMANDS 115--------------------- 116include::sequencer.txt[] 117 118EXAMPLES 119-------- 120`git revert HEAD~3`:: 121 122 Revert the changes specified by the fourth last commit in HEAD 123 and create a new commit with the reverted changes. 124 125`git revert -n master~5..master~2`:: 126 127 Revert the changes done by commits from the fifth last commit 128 in master (included) to the third last commit in master 129 (included), but do not create any commit with the reverted 130 changes. The revert only modifies the working tree and the 131 index. 132 133SEE ALSO 134-------- 135linkgit:git-cherry-pick[1] 136 137GIT 138--- 139Part of the linkgit:git[1] suite