git cherry-pick [commit] - The Koch Family
The Koch Family The Koch Family

Latest news

جاري التحميل ...

git cherry-pick [commit]


Customer Needs

My team already had a go-live app in a customer environment some months ago. We have been developing some new features for our next milestone. The situation is described in the picture below:

We used Git for our codebase management. The go-live app running on our customer environment was at version `v1`. The latest sprint release was at version `v7` for our developing app.

Our customers wanted to have two separated release packages for our current sprint release. We all know that it was easy to ship the package to the developing app. However, the issue was that how we just picked some features needed for the go-live app. We called this package was a hotfix.

Git Cherry-Picking

Fortunately, we found that Git provided a way to achieve this task. Actually, we had all commits on the branch `master` already. We created a new branch called `hotfix/v1.1` and we traced back which commits needed. We used cherry-picking for merging these commits to this branch.

For example, let's use git log to watch the commits. From `v2` to `v3`, we have the following commits:
commit abcde1
commit abcde2
commit abcde3
commit abcde4
....

From `v6` to `v7`, we have the following commits:
commit xyzwq1
commit xyzwq2
commit xyzwq3
commit xyzwq4
....

Then, let's use git cherry-pick to choose our desired commits (for sure, sometimes solving conflict is required). For example:
git cherry-pick abcde2
git cherry-pick abcde3
git cherry-pick xyzwq2
git cherry-pick xyzwq3
git cherry-pick xyzwq4

That's it. Happy coding!

Reference
[1]. https://git-scm.com/docs/git-cherry-pick

Comments



If you like the content of our blog, we hope to stay in constant communication, just enter your email to subscribe to the blog's express mail to receive new blog updates, and you can send a message by clicking on the button next ...

إتصل بنا

About the site

author The Koch Family <<  Welcome! I'm so glad that you stopped by Your Modern Family blog. Together, we will talk about raising kids, organizing the home and saving money! and Tips & tricks and more…

< Learn more ←

Blog stats

Sparkline 2513183

All Copyrights Reserved

The Koch Family

2020