CINXE.COM

Git - git-revert Documentation

<!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript"> const currentTheme = localStorage.getItem("theme") if (currentTheme) { const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches if ((prefersDarkScheme && currentTheme === "light") || (!prefersDarkScheme && currentTheme === "dark")) { document.documentElement.dataset.theme = currentTheme } } </script> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - git-revert Documentation</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.5a9bcd9ec21b07a9e60356c8218bc26d6d6da93d54762f4ee6fd0069846598da.css" integrity="sha256-WpvNnsIbB6nmA1bIIYvCbW1tqT1Udi9O5v0AaYRlmNo="> <script src="/js/modernizr.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a id="logo" href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" class="no-filter" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <div id="search-container"> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </div> <img src="/images/dark-mode.svg" id="dark-mode-button" /> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about">About</a> <ul> </ul> </li> <li> <a href="/doc" class="active">Documentation</a> <ul class="expanded"> <li> <a href="/docs" class="active">Reference</a> </li> <li> <a href="/book">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> </nav> </aside> <div id="content"> <div id='reference-version'> <a class="dropdown-trigger" id="reference-languages-trigger" data-panel-id="l10n-versions-dropdown" href="#"> English ▾</a> <div class='dropdown-panel right' id='l10n-versions-dropdown'> <header>Localized versions of <strong>git-revert</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/git-revert"><span class="version">English</span> </a> </li> <li> <a href="/docs/git-revert/fr"><span class="version">Français</span> </a> </li> <li> <a href="/docs/git-revert/pt_BR"><span class="version">Português (Brasil)</span> </a> </li> <li> <a href="/docs/git-revert/zh_HANS-CN"><span class="version">简体中文</span> </a> </li> </ol> <footer> Want to read in your language or fix typos?<br/> <a href="https://github.com/jnavila/git-manpages-l10n">You can help translate this page</a>. </footer> </div> <a class="dropdown-trigger" id="reference-topics-trigger" data-panel-id="topics-dropdown" href="#">Topics ▾</a> <div class='dropdown-panel right' id='topics-dropdown'> <div class='three-column'> <div class='column-left'> <h3 class='setup'>Setup and Config</h3> <ul class='unstyled'> <li> <a href="/docs/git"> git </a> </li> <li> <a href="/docs/git-config"> config </a> </li> <li> <a href="/docs/git-help"> help </a> </li> <li> <a href="/docs/git-bugreport"> bugreport </a> </li> <li> <a href="/doc/credential-helpers"> Credential helpers </a> </li> </ul> <h3 class='projects'>Getting and Creating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-init"> init </a> </li> <li> <a href="/docs/git-clone"> clone </a> </li> </ul> <h3 class='snapshotting'>Basic Snapshotting</h3> <ul class='unstyled'> <li> <a href="/docs/git-add"> add </a> </li> <li> <a href="/docs/git-status"> status </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-commit"> commit </a> </li> <li> <a href="/docs/git-notes"> notes </a> </li> <li> <a href="/docs/git-restore"> restore </a> </li> <li> <a href="/docs/git-reset"> reset </a> </li> <li> <a href="/docs/git-rm"> rm </a> </li> <li> <a href="/docs/git-mv"> mv </a> </li> </ul> <h3 class='branching'>Branching and Merging</h3> <ul class='unstyled'> <li> <a href="/docs/git-branch"> branch </a> </li> <li> <a href="/docs/git-checkout"> checkout </a> </li> <li> <a href="/docs/git-switch"> switch </a> </li> <li> <a href="/docs/git-merge"> merge </a> </li> <li> <a href="/docs/git-mergetool"> mergetool </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-stash"> stash </a> </li> <li> <a href="/docs/git-tag"> tag </a> </li> <li> <a href="/docs/git-worktree"> worktree </a> </li> </ul> <h3 class='sharing'>Sharing and Updating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-fetch"> fetch </a> </li> <li> <a href="/docs/git-pull"> pull </a> </li> <li> <a href="/docs/git-push"> push </a> </li> <li> <a href="/docs/git-remote"> remote </a> </li> <li> <a href="/docs/git-submodule"> submodule </a> </li> </ul> </div> <div class='column-middle'> <h3 class='inspection'>Inspection and Comparison</h3> <ul class='unstyled'> <li> <a href="/docs/git-show"> show </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-difftool"> difftool </a> </li> <li> <a href="/docs/git-range-diff"> range-diff </a> </li> <li> <a href="/docs/git-shortlog"> shortlog </a> </li> <li> <a href="/docs/git-describe"> describe </a> </li> </ul> <h3 class='patching'>Patching</h3> <ul class='unstyled'> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-cherry-pick"> cherry-pick </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-rebase"> rebase </a> </li> <li> <a href="/docs/git-revert"> revert </a> </li> </ul> <h3 class='debugging'>Debugging</h3> <ul class='unstyled'> <li> <a href="/docs/git-bisect"> bisect </a> </li> <li> <a href="/docs/git-blame"> blame </a> </li> <li> <a href="/docs/git-grep"> grep </a> </li> </ul> <h3 class='email'>Email</h3> <ul class='unstyled'> <li> <a href="/docs/git-am"> am </a> </li> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-format-patch"> format-patch </a> </li> <li> <a href="/docs/git-send-email"> send-email </a> </li> <li> <a href="/docs/git-request-pull"> request-pull </a> </li> </ul> <h3 class='external'>External Systems</h3> <ul class='unstyled'> <li> <a href="/docs/git-svn"> svn </a> </li> <li> <a href="/docs/git-fast-import"> fast-import </a> </li> </ul> <h3 class='server-admin'>Server Admin</h3> <ul class='unstyled'> <li> <a href="/docs/git-daemon"> daemon </a> </li> <li> <a href="/docs/git-update-server-info"> update-server-info </a> </li> </ul> </div> <div class='column-right'> <h3 class='guides'>Guides</h3> <ul class='unstyled'> <li> <a href="/docs/gitattributes"> gitattributes </a> </li> <li> <a href="/docs/gitcli"> Command-line interface conventions </a> </li> <li> <a href="/docs/giteveryday"> Everyday Git </a> </li> <li> <a href="/docs/gitfaq"> Frequently Asked Questions (FAQ) </a> </li> <li> <a href="/docs/gitglossary"> Glossary </a> </li> <li> <a href="/docs/githooks"> Hooks </a> </li> <li> <a href="/docs/gitignore"> gitignore </a> </li> <li> <a href="/docs/gitmodules"> gitmodules </a> </li> <li> <a href="/docs/gitrevisions"> Revisions </a> </li> <li> <a href="/docs/gitsubmodules"> Submodules </a> </li> <li> <a href="/docs/gittutorial"> Tutorial </a> </li> <li> <a href="/docs/gitworkflows"> Workflows </a> </li> <li> <a href="/docs/git#_guides"> All guides... </a> </li> </ul> <h3 class='admin'>Administration</h3> <ul class='unstyled'> <li> <a href="/docs/git-clean"> clean </a> </li> <li> <a href="/docs/git-gc"> gc </a> </li> <li> <a href="/docs/git-fsck"> fsck </a> </li> <li> <a href="/docs/git-reflog"> reflog </a> </li> <li> <a href="/docs/git-filter-branch"> filter-branch </a> </li> <li> <a href="/docs/git-instaweb"> instaweb </a> </li> <li> <a href="/docs/git-archive"> archive </a> </li> <li> <a href="/docs/git-bundle"> bundle </a> </li> </ul> <h3 class='plumbing'>Plumbing Commands</h3> <ul class='unstyled'> <li> <a href="/docs/git-cat-file"> cat-file </a> </li> <li> <a href="/docs/git-check-ignore"> check-ignore </a> </li> <li> <a href="/docs/git-checkout-index"> checkout-index </a> </li> <li> <a href="/docs/git-commit-tree"> commit-tree </a> </li> <li> <a href="/docs/git-count-objects"> count-objects </a> </li> <li> <a href="/docs/git-diff-index"> diff-index </a> </li> <li> <a href="/docs/git-for-each-ref"> for-each-ref </a> </li> <li> <a href="/docs/git-hash-object"> hash-object </a> </li> <li> <a href="/docs/git-ls-files"> ls-files </a> </li> <li> <a href="/docs/git-ls-tree"> ls-tree </a> </li> <li> <a href="/docs/git-merge-base"> merge-base </a> </li> <li> <a href="/docs/git-read-tree"> read-tree </a> </li> <li> <a href="/docs/git-rev-list"> rev-list </a> </li> <li> <a href="/docs/git-rev-parse"> rev-parse </a> </li> <li> <a href="/docs/git-show-ref"> show-ref </a> </li> <li> <a href="/docs/git-symbolic-ref"> symbolic-ref </a> </li> <li> <a href="/docs/git-update-index"> update-index </a> </li> <li> <a href="/docs/git-update-ref"> update-ref </a> </li> <li> <a href="/docs/git-verify-pack"> verify-pack </a> </li> <li> <a href="/docs/git-write-tree"> write-tree </a> </li> </ul> </div> </div> </div> <a class="dropdown-trigger" id="reference-versions-trigger" data-panel-id="previous-versions-dropdown" href="#"> Latest version ▾ </a> <span class="light d-flex">git-revert last updated in 2.44.0</span> <div class='dropdown-panel left' id='previous-versions-dropdown'> <header>Changes in the <strong>git-revert</strong> manual</header> <ol class='reference-previous-versions'> <li class="no-change"><span>2.44.1 &rarr; 2.49.0 no changes</span></li> <li> <a href="/docs/git-revert/2.44.0"><span class="version">2.44.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2024-02-23</em> </a> </li> <li class="no-change"><span>2.43.1 &rarr; 2.43.6 no changes</span></li> <li> <a href="/docs/git-revert/2.43.0"><span class="version">2.43.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2023-11-20</em> </a> </li> <li class="no-change"><span>2.39.1 &rarr; 2.42.4 no changes</span></li> <li> <a href="/docs/git-revert/2.39.0"><span class="version">2.39.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2022-12-12</em> </a> </li> <li class="no-change"><span>2.38.1 &rarr; 2.38.5 no changes</span></li> <li> <a href="/docs/git-revert/2.38.0"><span class="version">2.38.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2022-10-02</em> </a> </li> <li class="no-change"><span>2.37.1 &rarr; 2.37.7 no changes</span></li> <li> <a href="/docs/git-revert/2.37.0"><span class="version">2.37.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2022-06-27</em> </a> </li> <li class="no-change"><span>2.30.1 &rarr; 2.36.6 no changes</span></li> <li> <a href="/docs/git-revert/2.30.0"><span class="version">2.30.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2020-12-27</em> </a> </li> <li class="no-change"><span>2.27.1 &rarr; 2.29.3 no changes</span></li> <li> <a href="/docs/git-revert/2.27.0"><span class="version">2.27.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2020-06-01</em> </a> </li> <li class="no-change"><span>2.23.1 &rarr; 2.26.3 no changes</span></li> <li> <a href="/docs/git-revert/2.23.0"><span class="version">2.23.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2019-08-16</em> </a> </li> <li class="no-change"><span>2.22.1 &rarr; 2.22.5 no changes</span></li> <li> <a href="/docs/git-revert/2.22.0"><span class="version">2.22.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2019-06-07</em> </a> </li> <li class="no-change"><span>2.10.5 &rarr; 2.21.4 no changes</span></li> <li> <a href="/docs/git-revert/2.9.5"><span class="version">2.9.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2017-07-30</em> </a> </li> <li class="no-change"><span>2.8.6 no changes</span></li> <li> <a href="/docs/git-revert/2.7.6"><span class="version">2.7.6</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2017-07-30</em> </a> </li> <li> <a href="/docs/git-revert/2.6.7"><span class="version">2.6.7</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2017-05-05</em> </a> </li> <li class="no-change"><span>2.1.4 &rarr; 2.5.6 no changes</span></li> <li> <a href="/docs/git-revert/2.0.5"><span class="version">2.0.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">2014-12-17</em> </a> </li> <li>&nbsp;</li> </ol> <footer> <p>Check your version of git by running</p> <code class="command">git --version</code> </footer> </div> </div> <div id="main" data-pagefind-filter="category:reference" data-pagefind-meta="category:Reference" data-pagefind-weight="0.05" data-pagefind-body> <div class="sect1"> <h2 id="_name"><a class="anchor" href="#_name"></a>NAME</h2> <div class="sectionbody"> <div class="paragraph"> <p>git-revert - Revert some existing commits</p> </div> </div> </div> <div class="sect1"> <h2 id="_synopsis"><a class="anchor" href="#_synopsis"></a>SYNOPSIS</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><em>git revert</em> [--[no-]edit] [-n] [-m &lt;parent-number&gt;] [-s] [-S[&lt;keyid&gt;]] &lt;commit&gt;&#8230;&#8203; <em>git revert</em> (--continue | --skip | --abort | --quit)</pre> </div> </div> </div> <div class="sect1"> <h2 id="_description"><a class="anchor" href="#_description"></a>DESCRIPTION</h2> <div class="sectionbody"> <div class="paragraph"> <p>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).</p> </div> <div class="paragraph"> <p>Note: <em>git revert</em> 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 <a href='/docs/git-reset'>git-reset[1]</a>, particularly the <code>--hard</code> option. If you want to extract specific files as they were in another commit, you should see <a href='/docs/git-restore'>git-restore[1]</a>, specifically the <code>--source</code> option. Take care with these alternatives as both will discard uncommitted changes in your working directory.</p> </div> <div class="paragraph"> <p>See "Reset, restore and revert" in <a href='/docs/git'>git[1]</a> for the differences between the three commands.</p> </div> </div> </div> <div class="sect1"> <h2 id="_options"><a class="anchor" href="#_options"></a>OPTIONS</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt-ltcommitgt82308203"> <a class="anchor" href="#Documentation/git-revert.txt-ltcommitgt82308203"></a>&lt;commit&gt;&#8230;&#8203; </dt> <dd> <p>Commits to revert. For a more complete list of ways to spell commit names, see <a href='/docs/gitrevisions'>gitrevisions[7]</a>. Sets of commits can also be given but no traversal is done by default, see <a href='/docs/git-rev-list'>git-rev-list[1]</a> and its <code>--no-walk</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--e"> <a class="anchor" href="#Documentation/git-revert.txt--e"></a>-e </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---edit"> <a class="anchor" href="#Documentation/git-revert.txt---edit"></a>--edit </dt> <dd> <p>With this option, <em>git revert</em> will let you edit the commit message prior to committing the revert. This is the default if you run the command from a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--mparent-number"> <a class="anchor" href="#Documentation/git-revert.txt--mparent-number"></a>-m parent-number </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---mainlineparent-number"> <a class="anchor" href="#Documentation/git-revert.txt---mainlineparent-number"></a>--mainline parent-number </dt> <dd> <p>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.</p> <div class="paragraph"> <p>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.</p> </div> <div class="paragraph"> <p>See the <a href="/docs/howto/revert-a-faulty-merge">revert-a-faulty-merge How-To</a> for more details.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---no-edit"> <a class="anchor" href="#Documentation/git-revert.txt---no-edit"></a>--no-edit </dt> <dd> <p>With this option, <em>git revert</em> will not start the commit message editor.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---cleanupltmodegt"> <a class="anchor" href="#Documentation/git-revert.txt---cleanupltmodegt"></a>--cleanup=&lt;mode&gt; </dt> <dd> <p>This option determines how the commit message will be cleaned up before being passed on to the commit machinery. See <a href='/docs/git-commit'>git-commit[1]</a> for more details. In particular, if the <em>&lt;mode&gt;</em> is given a value of <code>scissors</code>, scissors will be appended to <code>MERGE_MSG</code> before being passed on in the case of a conflict.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--n"> <a class="anchor" href="#Documentation/git-revert.txt--n"></a>-n </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---no-commit"> <a class="anchor" href="#Documentation/git-revert.txt---no-commit"></a>--no-commit </dt> <dd> <p>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.</p> <div class="paragraph"> <p>This is useful when reverting more than one commits' effect to your index in a row.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--Sltkeyidgt"> <a class="anchor" href="#Documentation/git-revert.txt--Sltkeyidgt"></a>-S[&lt;keyid&gt;] </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---gpg-signltkeyidgt"> <a class="anchor" href="#Documentation/git-revert.txt---gpg-signltkeyidgt"></a>--gpg-sign[=&lt;keyid&gt;] </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---no-gpg-sign"> <a class="anchor" href="#Documentation/git-revert.txt---no-gpg-sign"></a>--no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--s"> <a class="anchor" href="#Documentation/git-revert.txt--s"></a>-s </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---signoff"> <a class="anchor" href="#Documentation/git-revert.txt---signoff"></a>--signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer at the end of the commit message. See the signoff option in <a href='/docs/git-commit'>git-commit[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---strategyltstrategygt"> <a class="anchor" href="#Documentation/git-revert.txt---strategyltstrategygt"></a>--strategy=&lt;strategy&gt; </dt> <dd> <p>Use the given merge strategy. Should only be used once. See the MERGE STRATEGIES section in <a href='/docs/git-merge'>git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--Xltoptiongt"> <a class="anchor" href="#Documentation/git-revert.txt--Xltoptiongt"></a>-X&lt;option&gt; </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---strategy-optionltoptiongt"> <a class="anchor" href="#Documentation/git-revert.txt---strategy-optionltoptiongt"></a>--strategy-option=&lt;option&gt; </dt> <dd> <p>Pass the merge strategy-specific option through to the merge strategy. See <a href='/docs/git-merge'>git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---rerere-autoupdate"> <a class="anchor" href="#Documentation/git-revert.txt---rerere-autoupdate"></a>--rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---no-rerere-autoupdate"> <a class="anchor" href="#Documentation/git-revert.txt---no-rerere-autoupdate"></a>--no-rerere-autoupdate </dt> <dd> <p>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. <code>--no-rerere-autoupdate</code> is a good way to double-check what <code>rerere</code> did and catch potential mismerges, before committing the result to the index with a separate <code>git add</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---reference"> <a class="anchor" href="#Documentation/git-revert.txt---reference"></a>--reference </dt> <dd> <p>Instead of starting the body of the log message with "This reverts &lt;full-object-name-of-the-commit-being-reverted&gt;.", refer to the commit using "--pretty=reference" format (cf. <a href='/docs/git-log'>git-log[1]</a>). The <code>revert.reference</code> configuration variable can be used to enable this option by default.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_sequencer_subcommands"><a class="anchor" href="#_sequencer_subcommands"></a>SEQUENCER SUBCOMMANDS</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt---continue"> <a class="anchor" href="#Documentation/git-revert.txt---continue"></a>--continue </dt> <dd> <p>Continue the operation in progress using the information in <code>.git/sequencer</code>. Can be used to continue after resolving conflicts in a failed cherry-pick or revert.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---skip"> <a class="anchor" href="#Documentation/git-revert.txt---skip"></a>--skip </dt> <dd> <p>Skip the current commit and continue with the rest of the sequence.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---quit"> <a class="anchor" href="#Documentation/git-revert.txt---quit"></a>--quit </dt> <dd> <p>Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---abort"> <a class="anchor" href="#Documentation/git-revert.txt---abort"></a>--abort </dt> <dd> <p>Cancel the operation and return to the pre-sequence state.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_examples"><a class="anchor" href="#_examples"></a>EXAMPLES</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt-codegitrevertHEAD3code"> <a class="anchor" href="#Documentation/git-revert.txt-codegitrevertHEAD3code"></a><code>git revert HEAD~3</code> </dt> <dd> <p>Revert the changes specified by the fourth last commit in HEAD and create a new commit with the reverted changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt-codegitrevert-nmaster5master2code"> <a class="anchor" href="#Documentation/git-revert.txt-codegitrevert-nmaster5master2code"></a><code>git revert -n master~5..master~2</code> </dt> <dd> <p>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.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_discussion"><a class="anchor" href="#_discussion"></a>DISCUSSION</h2> <div class="sectionbody"> <div class="paragraph"> <p>While git creates a basic commit message automatically, it is <em>strongly</em> recommended to explain why the original commit is being reverted. In addition, repeatedly reverting reverts will result in increasingly unwieldy subject lines, for example <em>Reapply "Reapply "&lt;original-subject&gt;""</em>. Please consider rewording these to be shorter and more unique.</p> </div> </div> </div> <div class="sect1"> <h2 id="_configuration"><a class="anchor" href="#_configuration"></a>CONFIGURATION</h2> <div class="sectionbody"> <div class="paragraph"> <p>Everything below this line in this section is selectively included from the <a href='/docs/git-config'>git-config[1]</a> documentation. The content is the same as what&#8217;s found there:</p> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt-revertreference"> <a class="anchor" href="#Documentation/git-revert.txt-revertreference"></a>revert.reference </dt> <dd> <p>Setting this variable to true makes <code>git revert</code> behave as if the <code>--reference</code> option is given.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_see_also"><a class="anchor" href="#_see_also"></a>SEE ALSO</h2> <div class="sectionbody"> <div class="paragraph"> <p><a href='/docs/git-cherry-pick'>git-cherry-pick[1]</a></p> </div> </div> </div> <div class="sect1"> <h2 id="_git"><a class="anchor" href="#_git"></a>GIT</h2> <div class="sectionbody"> <div class="paragraph"> <p>Part of the <a href='/docs/git'>git[1]</a> suite</p> </div> </div> </div> <h3 hidden="true" data-pagefind-weight="10">revert</h3> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/application.min.41cd14770f70d5443df414cb542804bc1226e3e08ab8983cb3f360dca36ece98.js" integrity="sha256-Qc0Udw9w1UQ99BTLVCgEvBIm4&#43;CKuJg8s/Ng3KNuzpg="></script> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10