Git checks out the specified commit to the current branch from another branch

Source: Internet
Author: User

Http://think-like-a-git.net/sections/rebase-from-the-ground-up/cherry-picking-explained.html

Git ' s own online help have a great, if characteristically terse, description of the command does:

Given one or more existing commits, apply the change from each one introduces, recording a new commits for each.

I ' ve already mentioned (back in the page about garbage collection) that a Git commit ' s ID was a hash of both its contents a nd its history. So, even if you have both commits that introduce the exact same change, if they point to different parent commits, they ' ll have different IDs.

What git cherry-pick does, basically, was take a commit from somewhere else, and "Play it back" wherever you were right now. Because this introduces the same change with a different parent, Git builds a new commit with a different ID.

Let's go example from the reachability section:

If you were at node H in this graph, and you typed git cherry-pick E (yes, you ' d actually type part or all of the SHA for the Comm It, but for simplicity ' s sake, I'll just use the labels that is already here), you ' d wind up with a copy of commit E -let's Call it "e-Prime" or E '-that pointed to H -s parent, like so:

Or, if you typed something like git cherry-pick C D E , you ' d wind up with the this when you were done:

The important thing to notice are that Git have copied changes made in one place, and replayed them somewhere else.

Here's a quick slideshow that steps through the process:

There is a series of pictures in the original, want to see, can go to see the original

Git checks out the specified commit to the current branch from another branch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.