Reader small image

You're reading from  Git for Programmers

Product typeBook
Published inJun 2021
PublisherPackt
ISBN-139781801075732
Edition1st Edition
Right arrow
Author (1)
Jesse Liberty
Jesse Liberty
author image
Jesse Liberty

Jesse Liberty is a full-time hands-on programmer, specializing in C#, git and .NET MAUI. He hosts the popular Yet Another Podcast and is the author of more than a dozen best-selling programming books. Liberty is a Certified Xamarin Developer, a Xamarin MVP and a Microsoft MVP. He was a Technical Evangelist for Microsoft, Distinguished Software Engineer at AT&T; Software Architect for PBS and Vice President of Information Technology at Citibank, and he was on the teaching staff at Brandeis University. Jesse is a recognized expert and has spoken at conferences world-wide.
Read more about Jesse Liberty

Right arrow

Cherry-picking

Sometimes you just need one or a small number of commits from one branch to be added to the tip of another branch. A common case is this: you have a release branch and a feature branch. The release branch is "frozen" but then you need to add a commit from a feature branch to the release branch (possibly a patch to fix a problem). When you cherry-pick, the picked commit goes to the tip of the branch you are cherry-picking onto.

An illustration will help. Here's our starting point:

Figure 5.13: Before cherry-picking

We discover that we do not want all of Feature1 on Main, but we do want Feature1B (it has the fix or feature set we need). To do this at the command line you enter git cherry-pick a2cb5f3 where a2cb5f3 is the ID of the feature commit you want to cherry-pick.

What you end up with looks like this:

Figure 5.14: After the cherry-pick

Notice that Feature1B is now added to the tip of main, but it is also left on the...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Git for Programmers
Published in: Jun 2021Publisher: PacktISBN-13: 9781801075732

Author (1)

author image
Jesse Liberty

Jesse Liberty is a full-time hands-on programmer, specializing in C#, git and .NET MAUI. He hosts the popular Yet Another Podcast and is the author of more than a dozen best-selling programming books. Liberty is a Certified Xamarin Developer, a Xamarin MVP and a Microsoft MVP. He was a Technical Evangelist for Microsoft, Distinguished Software Engineer at AT&T; Software Architect for PBS and Vice President of Information Technology at Citibank, and he was on the teaching staff at Brandeis University. Jesse is a recognized expert and has spoken at conferences world-wide.
Read more about Jesse Liberty