Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Git Best Practices Guide

You're reading from   Git Best Practices Guide Master the best practices of Git with the help of real-time scenarios to maximize team efficiency and workflow

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783553730
Length 102 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
PIDOUX Eric PIDOUX Eric
Author Profile Icon PIDOUX Eric
PIDOUX Eric
Arrow right icon
View More author details
Toc

Cherry-pick


This command lets you select a commit from a branch to apply it to another. The patch will be considered as a new commit in the selected branch.

Let's try to understand this by exploring the following example: Jim creates the jim branch from master and adds a new file in it:

Jim@local:~/webproject$ git checkout -b jim
Jim@local:~/webproject$ touch home.html
Jim@local:~/webproject$ git add home.html
Jim@local:~/webproject$ git commit -m 'add homepage'
Jim@local:~/webproject$ echo "<html>…</html>" > home.html
Jim@local:~/webproject$ git commit -a -m 'add content inside home'

As you can see, Jim creates the home.html file, adds it into Git, and commits it. Then he edits it and commits again. Now, let's see the commit history for this branch:

Jim@local:~/webproject$ git log --oneline
4f6ec45 add content inside home
22c45b7 add homepage

Now, Jim will apply the first commit to the master branch:

Jim@local:~/webproject$ git checkout master
Jim@local:~/webproject$ git cherry...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images