Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cherry pick multiple commits from a remote or upstream branch

Cherry pick multiple commits from a remote or upstream branch into your local branch.

Saw this from a comment on an answer on Stack Overflow

git fetch upstream
git cherry-pick A^..B

where A is the commit hash you want to start from (the ^ will include commit A instead of starting at next commit after A) and B is the commit you want to end after being applied.

If you run into merge conflicts, it's a simple process of:

  1. manually fixing the merge conflicts
  2. committing your changes (you may need to do this several times if you use the -p option)
  • git add -p - this will walk you through your changes and allow you to stage chunks instead of whole files so your commit messages can be more verbose/useful.
  • git commit
  1. continue the cherry picking (git cherry-pick --continue)
@moladukes
Copy link

moladukes commented Jun 6, 2017

🍻

@onkarbhat-bsn
Copy link

onkarbhat-bsn commented Feb 10, 2018

👍

@untra
Copy link

untra commented Dec 18, 2018

💯

@ihomway
Copy link

ihomway commented Sep 30, 2019

🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment