Hotfix with Git Cherry-Pick

Hotfix with Git Cherry-Pick

Daily short news for you
  • For over a week now, I haven't posted anything, not because I have nothing to write about, but because I'm looking for ways to distribute more valuable content in this rapidly exploding AI era.

    As I shared earlier this year, the number of visitors to my blog is gradually declining. When I looked at the statistics, the number of users in the first six months of 2025 has dropped by 30% compared to the same period last year, and by 15% compared to the last six months of 2024. This indicates a reality that users are gradually leaving. What is the reason for this?

    I think the biggest reason is that user habits have changed. They primarily discover the blog through search engines, with Google being the largest. Almost half of the users return to the blog without going through the search step. This is a positive signal, but it's still not enough to increase the number of new users. Not to mention that now, Google has launched the AI Search Labs feature, which means AI displays summarized content when users search, further reducing the likelihood of users accessing the website. Interestingly, when Search Labs was introduced, English articles have taken over the rankings for the most accessed content.

    My articles are usually very long, sometimes reaching up to 2000 words. Writing such an article takes a lot of time. It's normal for many articles to go unread. I know and accept this because not everyone encounters the issues being discussed. For me, writing is a way to cultivate patience and thoughtfulness. Being able to help someone through my writing is a wonderful thing.

    Therefore, I am thinking of focusing on shorter and medium-length content to be able to write more. Long content will only be used when I want to write in detail or delve deeply into a particular topic. So, I am looking for ways to redesign the blog. Everyone, please stay tuned! 😄

    » Read more
  • CloudFlare has introduced the pay per crawl feature to charge for each time AI "crawls" data from your website. What does that mean 🤔?

    The purpose of SEO is to help search engines see the website. When users search for relevant content, your website appears in the search results. This is almost a win-win situation where Google helps more people discover your site, and in return, Google gets more users.

    Now, the game with AI Agents is different. AI Agents have to actively seek out information sources and conveniently "crawl" your data, then mix it up or do something with it that we can't even know. So this is almost a game that benefits only one side 🤔!?

    CloudFlare's move is to make AI Agents pay for each time they retrieve data from your website. If they don’t pay, then I won’t let them read my data. Something like that. Let’s wait a bit longer and see 🤓.

    » Read more
  • Continuing to update on the lawsuit between the Deno group and Oracle over the name JavaScript: It seems that Deno is at a disadvantage as the court has dismissed the Deno group's complaint. However, in August, they (Oracle) must be held accountable for each reason, acknowledging or denying the allegations presented by the Deno group in the lawsuit.

    JavaScript™ Trademark Update

    » Read more

The Issue

I must say that ever since I learned how to use Git, I no longer need to copy the project to a new folder for "backup" every time I'm about to make a major change. Back in the days when I didn't know Git, that was the method I could come up with to safeguard my code in case there was a bug and I needed to revert.

Git is a version control tool that I believe is highly effective for most programmers. One of Git's standout features is its ability to create commits, which you can think of as "commitments," for each line of code you add. Each of these commitments is recorded in the history and can be easily reviewed, allowing you to return your code to that state.

For each individual or organization, there are different ways to use Git, creating diversity in workflows. "Flow" is a term that denotes the work process in Git. The most common example is having a master branch as the main branch, a development branch for ongoing development, and branches with prefixes like feature/01, feature/02... These branches are created from the development branch for continuous deployment of new features.

"Hotfix" is also a prefix in branches used to fix a specific issue in a production environment. After releasing an application, there might be an unexpected issue that requires an immediate fix. Such issues are considered critical and need to be addressed as a top priority. Typically, the solution is to check out a hotfix branch from the master branch, for example, hotfix/01, fix the issue, test it, and if everything is fine, merge hotfix/01 into both the development and master branches.

That's in the case when we've just finished a release and discovered a bug, or at least when the time between discovering the bug and the changes on the development branch isn't too extensive compared to the master branch. Conversely, if the development branch has undergone too many changes due to continuous feature development by the team, then the possibility of conflicts arising when merging a hotfix into the development branch becomes a concern.

This situation is also understandable because the new features may have modified the code at a different location than the master branch. When the master branch is "outdated," and a hotfix is merged, conflicts are likely to occur. To address this scenario, we need a method called "cherry-pick" for hotfixes.

Git Cherry-Pick

git cherry-pick is a Git command used to apply one or more commits from one branch to your current branch. This allows you to apply specific changes from commits without having to merge the entire branch.

For example, if you have a commit on a latest development branch that resolves a specific issue you need to apply to your product branch, you can use git cherry-pick to apply that commit to your current branch.

git cherry pick

Normally, when merging one branch into another, Git will take all the changes from the commits to merge. However, with "cherry-pick," you can select a single commit to bring into your branch.

Applied to the hotfix scenario mentioned above, we create a hotfix branch from the development branch, make the necessary code changes, commit them, and then cherry-pick that commit into the master branch.

To explain further, because the development branch always contains code newer than or equal to the master branch, creating a hotfix from the development branch, making the changes, and only "picking" that commit into the master branch reduces the risk of conflicts.

In a broader context, cherry-pick is not limited to hotfixes; it can be used in various other situations whenever you need to "pick" a commit into a specific branch without merging the entire branch.

Conclusion

git cherry-pick is used to apply one or more commits from one branch to another. In this article, we are discussing the use of cherry-pick for hotfixes, especially when the development branch has diverged significantly from the master branch and contains many changes. Instead of merging a hotfix from the master into the development branch, which can lead to code conflicts, we create a hotfix from the development branch and cherry-pick the commit into the master branch, reducing the risk of conflicts.

Premium
Hello

5 profound lessons

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

Every product comes with stories. The success of others is an inspiration for many to follow. 5 lessons learned have changed me forever. How about you? Click now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.

Comments (0)

Leave a comment...