Git merge -- add to pick (cherry-pick) -- merge only one commit

Source: Internet
Author: User
Cherry-pick Process

Some maintainers prefer to derive or pick up the contributor's code, rather than simply merging, because it can maintain a linear commit history. If you have completed the development of a feature and decided to introduce it into the main code, you can go
The feature branch then executes the derivative command. Fortunately, You Can resubmit these modifications on your main branch (or possibly the develop branch. If the code works well, you can quickly go to the master branch to obtain a linear commit history.
Another way to introduce code is to pick it up. Pick-up is similar to the combination of a specific submission. It first extracts the patch submitted, and then tries to apply it to the current branch. If a feature branch has multiple commits, but you only want to introduce one of them, you can use this method. It may also be because you like to pick up and hate the combination. Suppose you have a project similar to figure 5.26.

If you want to pull e43a6 to your trunk branch

$ Git cherry-pick e43a6fd3e94888d76779ad79fb568ed180e5fcdffinished one cherry-pick. [Master]: created a0a41a9: "More friendly message when locking the index fails. "3 files changed, 17 insertions (+), 3 deletions (-)

This will introduce the code of e43a6, but will get different SHA-1 values, because the application date is different. Your history now
It looks like figure 5.27.

Now, you can delete this feature branch and discard the commit that you don't want to introduce.

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.