Examples of using Git Cherry-pick

Source: Internet
Author: User
Tags using git

git cherry-pick is used to apply other commit modifications to the current commit.


git cherry-pick description of git documentation:
Apply the changes introduced by some existing commits
is to apply the existing commit (which is understood to be resubmitted)


In general, the two commits that do Cherry-pick are best adjacent . If there are several commits in the middle, then what interval commits are not taken when the Cherry-pick is done.


For example:

My present submission is: 68138b011d7eefbcc06c82a8577cc3935594910d.

There are two new submissions after this submission: 1c81f0129e62d2e79d5f2869c2b547bf17213e87 and 944cc2e483ff6ca86c9973e3cc7758c9030d17f6

I would like to bring these two new submissions to the following steps:

(1) Take the first one to submit:

[Wslu@wslu-cs postgres-xc]$ git cherry-pick 1c81f0129e62d2e79d5f2869c2b547bf17213e87
Automatic Cherry-pick failed. After resolving the conflicts,
Mark the corrected paths with ' git add <paths> ' or ' git rm <paths> '
and commit the result with:


Git commit-c 1c81f0129e62d2e79d5f2869c2b547bf17213e87


[Wslu@wslu-cs postgres-xc]$

Indicates a conflict, then manually resolve the conflict. And then execute

git add xxx1.c xxx2.c #将文件变动添加到索引

git commit--amend #追加到当前提交, which is the first commit.

Or

Git commit-c 1c81f0129e62d2e79d5f2869c2b547bf17213e87


(2) Take a second submission:

The procedure is the same as the first commit.


At this point, complete.




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.