LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-cherry-pick

Apply changes from existing commits

TLDR

Apply a commit to the current branch
$ git cherry-pick [commit]
copy
Cherry-pick multiple commits
$ git cherry-pick [commit1] [commit2]
copy
Cherry-pick an exclusive range (excludes start, includes end)
$ git cherry-pick [start]..[end]
copy
Cherry-pick an inclusive range (includes both start and end)
$ git cherry-pick [start]^..[end]
copy
Apply changes without committing
$ git cherry-pick -n [commit]
copy
Continue after resolving conflicts
$ git cherry-pick --continue
copy
Abort and return to pre-cherry-pick state
$ git cherry-pick --abort
copy
Append a "cherry picked from" note to the commit message
$ git cherry-pick -x [commit]
copy

SYNOPSIS

git cherry-pick [options] commit...git cherry-pick (--continue | --skip | --abort | --quit)

DESCRIPTION

git cherry-pick applies the changes introduced by existing commits onto the current branch, creating new commits with the same diff but different ancestry. This allows selective integration of specific changes without merging entire branches.The command is essential for backporting bug fixes to maintenance branches, incorporating specific features from development branches, and recovering commits from abandoned branches. Each cherry-picked commit gets a new SHA-1 hash reflecting its new parent.When specifying a range with `..`, the start commit is excluded. To include both endpoints use `start^..end`. Cherry-picking can encounter conflicts when changes don't apply cleanly to the target branch's context. The operation can be paused to allow manual resolution before continuing with `--continue`.

PARAMETERS

-e, --edit

Edit the commit message before committing.
-n, --no-commit
Apply changes to the working tree and index without creating a commit.
-x
Append a line saying "(cherry picked from commit ...)" to the original commit message. Useful for tracking backports on public branches.
-s, --signoff
Add a `Signed-off-by` trailer to the commit message.
-m parent-number, --mainline parent-number
Specify the parent number (starting from 1) to use as the mainline when cherry-picking a merge commit.
--ff
If HEAD is the same as the parent of the commit being cherry-picked, fast-forward HEAD instead of creating a new commit.
--continue
Continue the operation after resolving conflicts.
--skip
Skip the current commit and continue with the rest of the sequence.
--abort
Cancel the operation and return to the pre-cherry-pick state.
--quit
Forget the current operation without restoring HEAD, leaving the working tree as-is.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid