Single Cherry-Pick With multiple Commit

Jerry PM
2 min readMar 31, 2022

--

Using two methods

Photo by Yancy Min on Unsplash

Git cherry-pick one of the few very useful commands, useful for fetching one commit from another branch to yours. here’s how if you want to cherry-pick more than one commit.

Cherry-Pick Multiple Commit

Normal you can use this method, cherry-pick with multiple commit you can cherry-pick any number of commit hashes at once. This example by partial hash.

//commits one by one
$ git cherry-pick commit1 commit2 commit3 commit4 commit5
example:
$ git cherry-pick 1e038f10 2f028f10 34138b11
//commits by range
$ git cherry-pick A^..B
example:
$ git cherry-pick 6653c90^..481981f

Use App (Sourcetree)

I prefer this method, and often use it too, you can check the changes that occurred in the commit. First thing to do is to use sourcetree Interactive rebase (Rebase children of -commit- interactively), squash commit what you want to joined.

Source: Author

Squash commits that you want to merge (Squash with previous) and then click “ok”. Don’t forget to edit the commit message.

Source : https://www.atlassian.com/blog/sourcetree/interactive-rebase-sourcetree

force push you commit (example: $ git push -f origin branch/feature) after merging now cherry-pick from that branch to your branch.
(example: $ git cherry-pick 1e038f10)

--

--