git cherry pick

This is something that I always have to do once  a while but it’s not often enough that I remember exactly what the command is.  So that’s why I am writing it down here!

                            master branch -> some other changes1
feature branch -> changes1 -> changes2 -> changes3

PR for changes3 to master branch:
to get the commit hash for the changes that you want:

git log --oneline

switch to master branch:

git checkout master

create a new merge branch:

git checkout -b pr_branch

now cherry pick your changes to the pr_branch:

git cherry-pick [commit hash]

push your change branch to the remote repo:

git push origin pr_branch

courtesy of this post: from Ariejan de Vroom

Leave a Reply

Your email address will not be published. Required fields are marked *