CINXE.COM
Git - git-cherry-pick Documentation
<!DOCTYPE html> <html lang="en"> <head> <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-cherry-pick Documentation</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></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> <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> </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-cherry-pick</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/git-cherry-pick"><span class="version">English</span> </a> </li> <li> <a href="/docs/git-cherry-pick/fr"><span class="version">Français</span> </a> </li> <li> <a href="/docs/git-cherry-pick/pt_BR"><span class="version">Português (Brasil)</span> </a> </li> <li> <a href="/docs/git-cherry-pick/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-cherry-pick last updated in 2.45.0</span> <div class='dropdown-panel left' id='previous-versions-dropdown'> <header>Changes in the <strong>git-cherry-pick</strong> manual</header> <ol class='reference-previous-versions'> <li class="no-change"><span>2.45.1 → 2.47.1 no changes</span></li> <li> <a href="/docs/git-cherry-pick/2.45.0"><span class="version">2.45.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/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">04/29/24</em> </a> </li> <li class="no-change"><span>2.39.4 → 2.44.2 no changes</span></li> <li> <a href="/docs/git-cherry-pick/2.39.3"><span class="version">2.39.3</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">04/17/23</em> </a> </li> <li class="no-change"><span>2.38.1 → 2.39.2 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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/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">10/02/22</em> </a> </li> <li class="no-change"><span>2.35.1 → 2.37.7 no changes</span></li> <li> <a href="/docs/git-cherry-pick/2.35.0"><span class="version">2.35.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/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">01/24/22</em> </a> </li> <li class="no-change"><span>2.30.1 → 2.34.8 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">12/27/20</em> </a> </li> <li class="no-change"><span>2.27.1 → 2.29.3 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">06/01/20</em> </a> </li> <li class="no-change"><span>2.23.1 → 2.26.3 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">08/16/19</em> </a> </li> <li class="no-change"><span>2.22.1 → 2.22.5 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">06/07/19</em> </a> </li> <li class="no-change"><span>2.21.1 → 2.21.4 no changes</span></li> <li> <a href="/docs/git-cherry-pick/2.21.0"><span class="version">2.21.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/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">02/24/19</em> </a> </li> <li class="no-change"><span>2.10.5 → 2.20.5 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">07/30/17</em> </a> </li> <li class="no-change"><span>2.8.6 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">07/30/17</em> </a> </li> <li> <a href="/docs/git-cherry-pick/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">05/05/17</em> </a> </li> <li class="no-change"><span>2.4.12 → 2.5.6 no changes</span></li> <li> <a href="/docs/git-cherry-pick/2.3.10"><span class="version">2.3.10</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/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">09/28/15</em> </a> </li> <li class="no-change"><span>2.1.4 → 2.2.3 no changes</span></li> <li> <a href="/docs/git-cherry-pick/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">12/17/14</em> </a> </li> <li> </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-cherry-pick - Apply the changes introduced by 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 cherry-pick</em> [--edit] [-n] [-m <parent-number>] [-s] [-x] [--ff] [-S[<keyid>]] <commit>…​ <em>git cherry-pick</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, apply the change each one introduces, recording a new commit for each. This requires your working tree to be clean (no modifications from the HEAD commit).</p> </div> <div class="paragraph"> <p>When it is not obvious how to apply a change, the following happens:</p> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>The current branch and <code>HEAD</code> pointer stay at the last commit successfully made.</p> </li> <li> <p>The <code>CHERRY_PICK_HEAD</code> ref is set to point at the commit that introduced the change that is difficult to apply.</p> </li> <li> <p>Paths in which the change applied cleanly are updated both in the index file and in your working tree.</p> </li> <li> <p>For conflicting paths, the index file records up to three versions, as described in the "TRUE MERGE" section of <a href='/docs/git-merge'>git-merge[1]</a>. The working tree files will include a description of the conflict bracketed by the usual conflict markers <code><<<<<<<</code> and <code>>>>>>>></code>.</p> </li> <li> <p>No other modifications are made.</p> </li> </ol> </div> <div class="paragraph"> <p>See <a href='/docs/git-merge'>git-merge[1]</a> for some hints on resolving such conflicts.</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-cherry-pick.txt-ltcommitgt82308203"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-ltcommitgt82308203"></a><commit>…​ </dt> <dd> <p>Commits to cherry-pick. For a more complete list of ways to spell commits, see <a href='/docs/gitrevisions'>gitrevisions[7]</a>. Sets of commits can be passed but no traversal is done by default, as if the <code>--no-walk</code> option was specified, see <a href='/docs/git-rev-list'>git-rev-list[1]</a>. Note that specifying a range will feed all <commit>…​ arguments to a single revision walk (see a later example that uses <em>maint master..next</em>).</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--e"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--e"></a>-e </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---edit"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---edit"></a>--edit </dt> <dd> <p>With this option, <em>git cherry-pick</em> will let you edit the commit message prior to committing.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---cleanupltmodegt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---cleanupltmodegt"></a>--cleanup=<mode> </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><mode></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-cherry-pick.txt--x"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--x"></a>-x </dt> <dd> <p>When recording the commit, append a line that says "(cherry picked from commit …​)" to the original commit message in order to indicate which commit this change was cherry-picked from. This is done only for cherry picks without conflicts. Do not use this option if you are cherry-picking from your private branch because the information is useless to the recipient. If on the other hand you are cherry-picking between two publicly visible branches (e.g. backporting a fix to a maintenance branch for an older release from a development branch), adding this information can be useful.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--r"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--r"></a>-r </dt> <dd> <p>It used to be that the command defaulted to do <code>-x</code> described above, and <code>-r</code> was to disable it. Now the default is not to do <code>-x</code> so this option is a no-op.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--mltparent-numbergt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--mltparent-numbergt"></a>-m <parent-number> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---mainlineltparent-numbergt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---mainlineltparent-numbergt"></a>--mainline <parent-number> </dt> <dd> <p>Usually you cannot cherry-pick 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 cherry-pick to replay the change relative to the specified parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--n"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--n"></a>-n </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---no-commit"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---no-commit"></a>--no-commit </dt> <dd> <p>Usually the command automatically creates a sequence of commits. This flag applies the changes necessary to cherry-pick each named commit to your working tree and the index, without making any commit. In addition, when this option is used, your index does not have to match the HEAD commit. The cherry-pick is done against the beginning state of your index.</p> <div class="paragraph"> <p>This is useful when cherry-picking more than one commits' effect to your index in a row.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--s"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--s"></a>-s </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---signoff"> <a class="anchor" href="#Documentation/git-cherry-pick.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-cherry-pick.txt--Sltkeyidgt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--Sltkeyidgt"></a>-S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---gpg-signltkeyidgt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---gpg-signltkeyidgt"></a>--gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---no-gpg-sign"> <a class="anchor" href="#Documentation/git-cherry-pick.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-cherry-pick.txt---ff"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---ff"></a>--ff </dt> <dd> <p>If the current HEAD is the same as the parent of the cherry-pick’ed commit, then a fast forward to this commit will be performed.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---allow-empty"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---allow-empty"></a>--allow-empty </dt> <dd> <p>By default, cherry-picking an empty commit will fail, indicating that an explicit invocation of <code>git commit --allow-empty</code> is required. This option overrides that behavior, allowing empty commits to be preserved automatically in a cherry-pick. Note that when "--ff" is in effect, empty commits that meet the "fast-forward" requirement will be kept even without this option. Note also, that use of this option only keeps commits that were initially empty (i.e. the commit recorded the same tree as its parent). Commits which are made empty due to a previous commit will cause the cherry-pick to fail. To force the inclusion of those commits, use <code>--empty=keep</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---allow-empty-message"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---allow-empty-message"></a>--allow-empty-message </dt> <dd> <p>By default, cherry-picking a commit with an empty message will fail. This option overrides that behavior, allowing commits with empty messages to be cherry picked.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---emptydropkeepstop"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---emptydropkeepstop"></a>--empty=(drop|keep|stop) </dt> <dd> <p>How to handle commits being cherry-picked that are redundant with changes already in the current history.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codedropcode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codedropcode"></a><code>drop</code> </dt> <dd> <p>The commit will be dropped.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codekeepcode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codekeepcode"></a><code>keep</code> </dt> <dd> <p>The commit will be kept. Implies <code>--allow-empty</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codestopcode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codestopcode"></a><code>stop</code> </dt> <dd> <p>The cherry-pick will stop when the commit is applied, allowing you to examine the commit. This is the default behavior.</p> </dd> </dl> </div> </div> </div> <div class="paragraph"> <p>Note that <code>--empty=drop</code> and <code>--empty=stop</code> only specify how to handle a commit that was not initially empty, but rather became empty due to a previous commit. Commits that were initially empty will still cause the cherry-pick to fail unless one of <code>--empty=keep</code> or <code>--allow-empty</code> are specified.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---keep-redundant-commits"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---keep-redundant-commits"></a>--keep-redundant-commits </dt> <dd> <p>Deprecated synonym for <code>--empty=keep</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---strategyltstrategygt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---strategyltstrategygt"></a>--strategy=<strategy> </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-cherry-pick.txt--Xltoptiongt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt--Xltoptiongt"></a>-X<option> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---strategy-optionltoptiongt"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---strategy-optionltoptiongt"></a>--strategy-option=<option> </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-cherry-pick.txt---rerere-autoupdate"> <a class="anchor" href="#Documentation/git-cherry-pick.txt---rerere-autoupdate"></a>--rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---no-rerere-autoupdate"> <a class="anchor" href="#Documentation/git-cherry-pick.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> </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-cherry-pick.txt---continue"> <a class="anchor" href="#Documentation/git-cherry-pick.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-cherry-pick.txt---skip"> <a class="anchor" href="#Documentation/git-cherry-pick.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-cherry-pick.txt---quit"> <a class="anchor" href="#Documentation/git-cherry-pick.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-cherry-pick.txt---abort"> <a class="anchor" href="#Documentation/git-cherry-pick.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-cherry-pick.txt-codegitcherry-pickmastercode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pickmastercode"></a><code>git cherry-pick master</code> </dt> <dd> <p>Apply the change introduced by the commit at the tip of the master branch and create a new commit with this change.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmastercode-1"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pickmastercode-1"></a><code>git cherry-pick ..master</code> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickHEADmastercode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pickHEADmastercode"></a><code>git cherry-pick ^HEAD master</code> </dt> <dd> <p>Apply the changes introduced by all commits that are ancestors of master but not of HEAD to produce new commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmaintnextmastercode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pickmaintnextmastercode"></a><code>git cherry-pick maint next ^master</code> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmaintmasternextcode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pickmaintmasternextcode"></a><code>git cherry-pick maint master..next</code> </dt> <dd> <p>Apply the changes introduced by all commits that are ancestors of maint or next, but not master or any of its ancestors. Note that the latter does not mean <code>maint</code> and everything between <code>master</code> and <code>next</code>; specifically, <code>maint</code> will not be used if it is included in <code>master</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmaster4master2code"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pickmaster4master2code"></a><code>git cherry-pick master~4 master~2</code> </dt> <dd> <p>Apply the changes introduced by the fifth and third last commits pointed to by master and create 2 new commits with these changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pick-nmaster1nextcode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pick-nmaster1nextcode"></a><code>git cherry-pick -n master~1 next</code> </dt> <dd> <p>Apply to the working tree and the index the changes introduced by the second last commit pointed to by master and by the last commit pointed to by next, but do not create any commit with these changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pick--ffnextcode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitcherry-pick--ffnextcode"></a><code>git cherry-pick --ff ..next</code> </dt> <dd> <p>If history is linear and HEAD is an ancestor of next, update the working tree and advance the HEAD pointer to match next. Otherwise, apply the changes introduced by those commits that are in next but not HEAD to the current branch, creating a new commit for each new change.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitrev-list--reversemaster--READMEgitcherry-pick-n--stdincode"> <a class="anchor" href="#Documentation/git-cherry-pick.txt-codegitrev-list--reversemaster--READMEgitcherry-pick-n--stdincode"></a><code>git rev-list --reverse master -- README | git cherry-pick -n --stdin</code> </dt> <dd> <p>Apply the changes introduced by all commits on the master branch that touched README to the working tree and index, so the result can be inspected and made into a single new commit if suitable.</p> </dd> </dl> </div> <div class="paragraph"> <p>The following sequence attempts to backport a patch, bails out because the code the patch applies to has changed too much, and then tries again, this time exercising more care about matching up context lines.</p> </div> <div class="listingblock"> <div class="content"> <pre>$ git cherry-pick topic^ <b class="conum">(1)</b> $ git diff <b class="conum">(2)</b> $ git cherry-pick --abort <b class="conum">(3)</b> $ git cherry-pick -Xpatience topic^ <b class="conum">(4)</b></pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>apply the change that would be shown by <code>git show topic^</code>. In this example, the patch does not apply cleanly, so information about the conflict is written to the index and working tree and no new commit results.</p> </li> <li> <p>summarize changes to be reconciled</p> </li> <li> <p>cancel the cherry-pick. In other words, return to the pre-cherry-pick state, preserving any local modifications you had in the working tree.</p> </li> <li> <p>try to apply the change introduced by <code>topic^</code> again, spending extra time to avoid mistakes based on incorrectly matching context lines.</p> </li> </ol> </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-revert'>git-revert[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="7">cherry-pick</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.js"></script> </div> </body> </html>