Use

git cherry-pick <commit>

to apply <commit> to your current branch.

I myself would probably cross-check the commits I pick in gitk and cherry-pick them with right-clicks on the commit entry there instead.


If you want to go more automatic (with all its dangers) and assuming all commits since yesterday happened on wss you could generate the list of commits using git log (with --pretty suggested by Jefromi)

git log --reverse --since=yesterday --pretty=%H

so everything together assuming you use bash

for commit in $(git log --reverse --since=yesterday --pretty=%H);
do
    git cherry-pick $commit
done

If something goes wrong here (there is a lot of potential) you are in trouble since this works on the live checkout, so either do manual cherry-picks or use rebase like suggested by Jefromi.

Answer from Benjamin Bannier on Stack Overflow
🌐
GitLab
docs.gitlab.com › topics › git › cherry_pick
Cherry-pick changes with Git | GitLab Docs
Check out the branch you want to cherry-pick into: ... Use the git cherry-pick command with the -m option and the index of the parent commit you want to use as the mainline. Replace <merge-commit-hash> with the SHA of the merge commit and <parent_index> with the index of the parent commit.
Top answer
1 of 11
1568

Use

git cherry-pick <commit>

to apply <commit> to your current branch.

I myself would probably cross-check the commits I pick in gitk and cherry-pick them with right-clicks on the commit entry there instead.


If you want to go more automatic (with all its dangers) and assuming all commits since yesterday happened on wss you could generate the list of commits using git log (with --pretty suggested by Jefromi)

git log --reverse --since=yesterday --pretty=%H

so everything together assuming you use bash

for commit in $(git log --reverse --since=yesterday --pretty=%H);
do
    git cherry-pick $commit
done

If something goes wrong here (there is a lot of potential) you are in trouble since this works on the live checkout, so either do manual cherry-picks or use rebase like suggested by Jefromi.

2 of 11
740

You should really have a workflow that lets you do this all by merging:

- x - x - x (v2) - x - x - x (v2.1)
           \
            x - x - x (wss)

So all you have to do is git checkout v2.1 and git merge wss. If for some reason you really can't do this, and you can't use git rebase to move your wss branch to the right place, the command to grab a single commit from somewhere and apply it elsewhere is git cherry-pick. Just check out the branch you want to apply it on, and run git cherry-pick <SHA of commit to cherry-pick>.

Some of the ways rebase might save you:

If your history looks like this:

- x - x - x (v2) - x - x - x (v2.1)
           \
            x - x - x (v2-only) - x - x - x (wss)

You could use git rebase --onto v2 v2-only wss to move wss directly onto v2:

- x - x - x (v2) - x - x - x (v2.1)
          |\
          |  x - x - x (v2-only)
           \
             x - x - x (wss)

Then you can merge! If you really, really, really can't get to the point where you can merge, you can still use rebase to effectively do several cherry-picks at once:

# wss-starting-point is the SHA1/branch immediately before the first commit to rebase
git branch wss-to-rebase wss
git rebase --onto v2.1 wss-starting-point wss-to-rebase
git checkout v2.1
git merge wss-to-rebase

Note: the reason that it takes some extra work in order to do this is that it's creating duplicate commits in your repository. This isn't really a good thing - the whole point of easy branching and merging is to be able to do everything by making commit(s) one place and merging them into wherever they're needed. Duplicate commits mean an intent never to merge those two branches (if you decide you want to later, you'll get conflicts).

Discussions

git - How to cherry pick from 1 branch to another - Stack Overflow
I have 2 branches, master and dev. I am on dev branch and I want to cherry-pick 1 commit from master to dev. So I did $ git cherry-pick be530cec7748e037c665bd5a585e6d9ce11bc8ad Finished one cherry- More on stackoverflow.com
🌐 stackoverflow.com
How can I replicate the MR cherry-pick function from the UI using the cli tool?
Huh? You mean how do you do git cherry-pick ? More on reddit.com
🌐 r/gitlab
6
3
October 13, 2024
How to properly move a commit from one branch to another now, if the two branches will be merged later?

i think you can do git reset soft head 1, then stash your changes then checkout the other branch, stash apply, then do the commit there

More on reddit.com
🌐 r/git
12
8
May 21, 2023
Is there an easy way to apply a commit from one branch to a different branch?
You want to look at cherry picking. More on reddit.com
🌐 r/git
6
2
October 7, 2022
People also ask

What does git cherry-pick do?
git cherry-pick copies the changes from a single commit and applies them as a new commit on your current branch, without merging or rebasing the whole branch.
🌐
boot.dev
boot.dev › blog › devops › git cherry-pick: copy one commit to another branch
Git Cherry-Pick: Copy One Commit to Another Branch | Boot.dev
Does git cherry-pick move or copy a commit?
It copies. The original commit stays on its branch, and the cherry-picked version is a new commit with a new hash because it has a different parent.
🌐
boot.dev
boot.dev › blog › devops › git cherry-pick: copy one commit to another branch
Git Cherry-Pick: Copy One Commit to Another Branch | Boot.dev
Can you cherry-pick multiple commits at once?
Yes. Pass multiple commit hashes to git cherry-pick, or a range like A^..B to apply every commit from A through B in order.
🌐
boot.dev
boot.dev › blog › devops › git cherry-pick: copy one commit to another branch
Git Cherry-Pick: Copy One Commit to Another Branch | Boot.dev
🌐
Atlassian
atlassian.com › git › tutorials › cherry pick
Git Cherry Pick | Atlassian Git Tutorial
December 15, 2025 - git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick ...
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › How-to-git-cherry-pick-from-another-branch-to-your-own
How to 'git cherry-pick' from another branch example
Since the repo was just initialized, all of this will occur on the master branch. /c/ git cherry-pick example (master) $ echo 'abba' > abba.html $ git add . | git commit -m '1st commit: 1 file' $ echo 'bowie' > bowie.html $ git add . | git commit -m '2nd commit: 2 files' $ echo 'chilliwack' > chilliwack.html $ git add . | git commit -m '3rd commit: 3 files' We are about to git cherry-pick from another branch, and specifically, we will be pulling in the second commit, but before we do we will delete all of these files and perform a commit to put the master branch back into an empty state.
🌐
Git
git-scm.com › docs › git-cherry-pick
Git - git-cherry-pick Documentation
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. git rev-list --reverse master -- README | git cherry-pick -n --stdin
Find elsewhere
🌐
Christian Engvall
christianengvall.se › git-cherry-pick
Git cherry pick from another branch | Christian Engvall
July 11, 2018 - git cherry-pick -x ea6128347797b9c268d95257ef17cb6ac0baaaab · By providing -x we get a message appended to the commit that says this commit was cherry picked: ... This creates a new commit with the changes from the cherry picked commit. If the changes introduced a merge conflict you must fix that first. Since the cherry pick above is a new commit, and not a merged commit from our feature-branch.
🌐
Entelligence
entelligence.ai › blogs › cherry-pick-commit-another-branch
How to Cherry Pick a Commit from Another Branch?
November 6, 2025 - Use git cherry-pick <hash> to apply one specific commit to another branch without merging the whole branch.
🌐
Better Programming
betterprogramming.pub › git-cherry-pick-selecting-specific-commits-to-merge-f1bf245e052a
Git Cherry Pick - Select specific commits to merge | by Carlos Fernando Arboleda Garcés | Better Programming
December 13, 2023 - Fortunately, my teammates had already solved this before and had an ace up their sleeve: git cherry-pick. This Git command makes it possible to apply existing commits to another branch by picking the specific commits that you need.
🌐
Boot.dev
boot.dev › blog › devops › git cherry-pick: copy one commit to another branch
Git Cherry-Pick: Copy One Commit to Another Branch | Boot.dev
1 month ago - There comes a time in every developer's ... git cherry-pick solves this: it takes a single commit from anywhere in your repo and applies it to your current branch, no full merge required....
🌐
JetBrains
jetbrains.com › guide › tips › cherry-pick-commit-diff-branch
Cherry Pick a Commit to a Different Branch - JetBrains Guide
March 23, 2023 - On the newly created branch, we can select the bugfix commit from the other branch and select "cherry pick" to apply that commit to our current branch. As we can see, the bugfix commit is now on the bugfix branch.
🌐
CloudBees
cloudbees.com › blog › git-cherry-pick-getting-the-exact-commit-you-want
Git Cherry Pick: Getting the Exact Commit You Want
August 12, 2021 - The easiest and most common way of using it is cherry-picking a single commit: git cherry-pick <COMMIT HASH>. ... After executing the commands above, you’ll have a repository with a single commit.
🌐
DataCamp
campus.datacamp.com › courses › advanced-git › git-history-and-exploration
Cherry-Picking | Git
Git cherry-pick` is a command that copies a specific commit from one branch and applies it to another. Unlike merging or rebasing, which typically involve multiple commits, cherry-picking deals with individual commits.
🌐
Tollmanz
tollmanz.com › git-cherry-pick-range
Cherry Picking a Range of Commits with Git | tollmanz.com
Git has many methods for merging branchs, including the very unsophisticated cherry pick method. Its primary purpose it to copy individual commits from one branch to another.
🌐
DEV Community
dev.to › deshanm › pick-a-commit-from-another-branch-to-the-current-branch-cherry-pick-38p
Pick a commit from another branch to the current branch (cherry-pick) - DEV Community
July 26, 2020 - So you can cherry-pick them · Checkout to the branch that has the required commit. Then get git hash of that commit by using CLI or Github site
🌐
GitConnected
levelup.gitconnected.com › a-simple-guide-for-git-cherry-picking-in-tortoisegit-61c3440e5ad6
A simple guide for Git cherry picking in TortoiseGit 🍒 | by Miroslav Šlapka | Level Up Coding
February 23, 2021 - Git cherry pick is a command that enables us to pick a commit that we want from one branch and apply it to another branch. I think that’s the most common scenario. As an example let’s assume we have 2 branches.
🌐
PreviousNext
previousnext.com.au › blog › intro-cherry-picking-git
Intro to Cherry Picking with Git | PreviousNext
March 17, 2022 - Sometimes you don't want to merge a whole branch into another, and only need to pick one or two specific commits. This process is called 'cherry picking'. I will try to explaining this through a scenario which will make it easier to understand. Let’s say you are working in an project where you are making changes in a branch called new-features. You have already made a few commits but want to move just one of them into the master branch. From new-features branch run git ...
🌐
Kenokivabe
blogs.kenokivabe.com › article › cherry-pick-specific-commits-across-branches
Cherry-pick Specific Commits Across Branches - Keno Kivabe
git cherry-pick is a powerful command that allows you to take an individual commit (or a range of commits) from one branch and apply it onto another branch.
🌐
DEV Community
dev.to › grepliz › how-to-cherry-pick-commits-into-a-new-branch-284n
How to Cherry Pick Commits into a New Branch - DEV Community
December 22, 2020 - 02705d38d4 Fabien Villepinte l10n: fr.po Fix some typos from round3 5a05494049 Fabien Villepinte l10n: fr.po Fix some typos ca1b411648 Johannes Schindelin mingw: safe-guard a bit more against getenv` I then pipe that into grep "Liz Lam" to only get commits by me. Once I have a list of commits by me, I'll inspect and manually pick the ones I'm interested in. Let's pretend I came up with a list like this: ... I then create a new branch and cherry pick the list of SHA1 commits: git checkout -b my_new_branch git cherry-pick ff92f85cac git cherry-pick c8879ed156 git cherry-pick b01cb9a3f9
🌐
karmareka
karmareka.weebly.com › blog › git-cherry-pick-from-another-branch
Git cherry pick from another branch - karmareka
October 3, 2023 - Here an interesting article concerning cherry-pick. The cherry-pick is done against the beginning state of your index. In addition, when this option is used, your index does not have to match the...