Copy a single commit to another branch using cherry-pick
Today I was working on a new feature. I created a new branch
While a was working on it, I noticed some code that, if improved, would have made the development process much easier. So I improved it.
Once I was done, I committed the code and pushed to the remote. I started a merge request and assigned it to another developer.
Then, after a celebration coffee, I started working on yet another new feature,
feature/update-log-component, and I wanted to use the code improvements from
Instead of copying the code manually, thus creating two commits in the repository history with the same change, it would have been nice to bring the commit from
This is possible with git cherry-pick.
You only need the SHA of the commit you want to copy, let’s say
Be sure to checkout the branch you are working on now.
git checkout feature/update-log-component git cherry-pick 4350a96303c474812523c1214f50ffda1f2e437a
en voilà, the improved code is also on my current branch.
Leave a comment