logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-revert.1 (8262B)


  1. '\" t
  2. .\" Title: git-revert
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-REVERT" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-revert \- Revert some existing commits
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit revert\fR [\-\-[no\-]edit] [\-n] [\-m <parent\-number>] [\-s] [\-S[<keyid>]] <commit>\&...\:
  36. \fIgit revert\fR (\-\-continue | \-\-skip | \-\-abort | \-\-quit)
  37. .fi
  38. .SH "DESCRIPTION"
  39. .sp
  40. Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them\&. This requires your working tree to be clean (no modifications from the HEAD commit)\&.
  41. .sp
  42. Note: \fIgit revert\fR is used to record some new commits to reverse the effect of some earlier commits (often only a faulty one)\&. If you want to throw away all uncommitted changes in your working directory, you should see \fBgit-reset\fR(1), particularly the \fB\-\-hard\fR option\&. If you want to extract specific files as they were in another commit, you should see \fBgit-restore\fR(1), specifically the \fB\-\-source\fR option\&. Take care with these alternatives as both will discard uncommitted changes in your working directory\&.
  43. .sp
  44. See "Reset, restore and revert" in \fBgit\fR(1) for the differences between the three commands\&.
  45. .SH "OPTIONS"
  46. .PP
  47. <commit>\&...\:
  48. .RS 4
  49. Commits to revert\&. For a more complete list of ways to spell commit names, see
  50. \fBgitrevisions\fR(7)\&. Sets of commits can also be given but no traversal is done by default, see
  51. \fBgit-rev-list\fR(1)
  52. and its
  53. \fB\-\-no\-walk\fR
  54. option\&.
  55. .RE
  56. .PP
  57. \-e, \-\-edit
  58. .RS 4
  59. With this option,
  60. \fIgit revert\fR
  61. will let you edit the commit message prior to committing the revert\&. This is the default if you run the command from a terminal\&.
  62. .RE
  63. .PP
  64. \-m parent\-number, \-\-mainline parent\-number
  65. .RS 4
  66. Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline\&. This option specifies the parent number (starting from 1) of the mainline and allows revert to reverse the change relative to the specified parent\&.
  67. .sp
  68. Reverting a merge commit declares that you will never want the tree changes brought in by the merge\&. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge\&. This may or may not be what you want\&.
  69. .sp
  70. See the
  71. \m[blue]\fBrevert\-a\-faulty\-merge How\-To\fR\m[]\&\s-2\u[1]\d\s+2
  72. for more details\&.
  73. .RE
  74. .PP
  75. \-\-no\-edit
  76. .RS 4
  77. With this option,
  78. \fIgit revert\fR
  79. will not start the commit message editor\&.
  80. .RE
  81. .PP
  82. \-\-cleanup=<mode>
  83. .RS 4
  84. This option determines how the commit message will be cleaned up before being passed on to the commit machinery\&. See
  85. \fBgit-commit\fR(1)
  86. for more details\&. In particular, if the
  87. \fI<mode>\fR
  88. is given a value of
  89. \fBscissors\fR, scissors will be appended to
  90. \fBMERGE_MSG\fR
  91. before being passed on in the case of a conflict\&.
  92. .RE
  93. .PP
  94. \-n, \-\-no\-commit
  95. .RS 4
  96. Usually the command automatically creates some commits with commit log messages stating which commits were reverted\&. This flag applies the changes necessary to revert the named commits to your working tree and the index, but does not make the commits\&. In addition, when this option is used, your index does not have to match the HEAD commit\&. The revert is done against the beginning state of your index\&.
  97. .sp
  98. This is useful when reverting more than one commits\*(Aq effect to your index in a row\&.
  99. .RE
  100. .PP
  101. \-S[<keyid>], \-\-gpg\-sign[=<keyid>], \-\-no\-gpg\-sign
  102. .RS 4
  103. GPG\-sign commits\&. The
  104. \fBkeyid\fR
  105. argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space\&.
  106. \fB\-\-no\-gpg\-sign\fR
  107. is useful to countermand both
  108. \fBcommit\&.gpgSign\fR
  109. configuration variable, and earlier
  110. \fB\-\-gpg\-sign\fR\&.
  111. .RE
  112. .PP
  113. \-s, \-\-signoff
  114. .RS 4
  115. Add a
  116. \fBSigned\-off\-by\fR
  117. trailer at the end of the commit message\&. See the signoff option in
  118. \fBgit-commit\fR(1)
  119. for more information\&.
  120. .RE
  121. .PP
  122. \-\-strategy=<strategy>
  123. .RS 4
  124. Use the given merge strategy\&. Should only be used once\&. See the MERGE STRATEGIES section in
  125. \fBgit-merge\fR(1)
  126. for details\&.
  127. .RE
  128. .PP
  129. \-X<option>, \-\-strategy\-option=<option>
  130. .RS 4
  131. Pass the merge strategy\-specific option through to the merge strategy\&. See
  132. \fBgit-merge\fR(1)
  133. for details\&.
  134. .RE
  135. .PP
  136. \-\-rerere\-autoupdate, \-\-no\-rerere\-autoupdate
  137. .RS 4
  138. After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution\&.
  139. \fB\-\-no\-rerere\-autoupdate\fR
  140. is a good way to double\-check what
  141. \fBrerere\fR
  142. did and catch potential mismerges, before committing the result to the index with a separate
  143. \fBgit\fR
  144. \fBadd\fR\&.
  145. .RE
  146. .PP
  147. \-\-reference
  148. .RS 4
  149. Instead of starting the body of the log message with "This reverts <full\-object\-name\-of\-the\-commit\-being\-reverted>\&.", refer to the commit using "\-\-pretty=reference" format (cf\&.
  150. \fBgit-log\fR(1))\&. The
  151. \fBrevert\&.reference\fR
  152. configuration variable can be used to enable this option by default\&.
  153. .RE
  154. .SH "SEQUENCER SUBCOMMANDS"
  155. .PP
  156. \-\-continue
  157. .RS 4
  158. Continue the operation in progress using the information in \&.\fBgit/sequencer\fR\&. Can be used to continue after resolving conflicts in a failed cherry\-pick or revert\&.
  159. .RE
  160. .PP
  161. \-\-skip
  162. .RS 4
  163. Skip the current commit and continue with the rest of the sequence\&.
  164. .RE
  165. .PP
  166. \-\-quit
  167. .RS 4
  168. Forget about the current operation in progress\&. Can be used to clear the sequencer state after a failed cherry\-pick or revert\&.
  169. .RE
  170. .PP
  171. \-\-abort
  172. .RS 4
  173. Cancel the operation and return to the pre\-sequence state\&.
  174. .RE
  175. .SH "EXAMPLES"
  176. .PP
  177. \fBgit\fR \fBrevert\fR \fBHEAD~3\fR
  178. .RS 4
  179. Revert the changes specified by the fourth last commit in HEAD and create a new commit with the reverted changes\&.
  180. .RE
  181. .PP
  182. \fBgit\fR \fBrevert\fR \fB\-n\fR \fBmaster~5\fR\fB\&.\&.\fR\fBmaster~2\fR
  183. .RS 4
  184. Revert the changes done by commits from the fifth last commit in master (included) to the third last commit in master (included), but do not create any commit with the reverted changes\&. The revert only modifies the working tree and the index\&.
  185. .RE
  186. .SH "DISCUSSION"
  187. .sp
  188. While git creates a basic commit message automatically, it is \fIstrongly\fR recommended to explain why the original commit is being reverted\&. In addition, repeatedly reverting reverts will result in increasingly unwieldy subject lines, for example \fIReapply "Reapply "<original\-subject>""\fR\&. Please consider rewording these to be shorter and more unique\&.
  189. .SH "CONFIGURATION"
  190. .sp
  191. Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
  192. .PP
  193. revert\&.reference
  194. .RS 4
  195. Setting this variable to true makes
  196. \fBgit\fR
  197. \fBrevert\fR
  198. behave as if the
  199. \fB\-\-reference\fR
  200. option is given\&.
  201. .RE
  202. .SH "SEE ALSO"
  203. .sp
  204. \fBgit-cherry-pick\fR(1)
  205. .SH "GIT"
  206. .sp
  207. Part of the \fBgit\fR(1) suite
  208. .SH "NOTES"
  209. .IP " 1." 4
  210. revert-a-faulty-merge How-To
  211. .RS 4
  212. \%git-htmldocs/howto/revert-a-faulty-merge.html
  213. .RE