Cherry picking

Learn
1 min readApr 16, 2024

--

Each of those cherries are commits on a Git branch.

I was working on my forked code base, and had made a bunch of commits on the master branch. When I tried to merge to the original code base, I realized that the PR needs to be from develop to develop

So, I need to move the cherries from the master branch to develop branch.

I thought I will just switch branches on my local using git checkout develop , and commit my cherries there. Did not work. build folders and everything else that I did not want to commit got committed instead.

The solution was to revert the commits / cherries from the master branch, jump to develop branch and cherry-pick those commit-hashes and then push those commits from the develop branch.

Representative syntax would be

git checkout master
git revert commit-hash-one
git revert commit-hash-seven

git checkout develop
git cherry-pick commit-hash-one
git cherry-pick commit-hash-seven

git push

--

--

Learn
Learn

Written by Learn

On a continuing learning journey..

No responses yet