Git merges two remote libraries and git merges

Source: Internet
Author: User

Git merges two remote libraries and git merges

Environment:
1. The local disk is empty and there is nothing
2. There are two different projects (projects) on the remote git
3. merge the two projects locally
Commencement:
1. clone the code of the first project from the remote end and switch to the branch you want to merge.
Git clone git@xxx.com/project_1.git // This operation will create a local project_1 folder with project 1 code. Cd project_1git checkout project_1_v1 // This operation will switch the code to the project_1_v1 branch.
2. clone the code of the second project from the remote end and switch to the branch you want to merge.
Git clone git@xxx.com/project_2.git // This operation will create a local project_2 folder, which is the code of Project 2. Cd project_2git checkout project_2_v1 // This operation will switch the code to the project_2_v1 branch.
3. If we want to merge project_2 code into project_1 from the perspective of project_1. Therefore, we enter project_1
cd project_1
4. Add project_2 as a remote repository to project_1 and set the alias to other.
git remote add other ../project_2/
5. capture data from project_2 warehouse to this warehouse
git fetch other
6. The project_2_v1 branch captured from the project_2 warehouse is used as the new branch checkout to the local device. The new branch name is set to project_1_v2.
git checkout -b project_1_v2 other/project_2_v1
7. Now, from the perspective of project_1_v1, we want to merge project_1_v2 into project_1_v1 (because project_1_v2 is from project_2). Therefore, we need to switch to the project_1_v1 branch.
git checkout project_1_v1
8. Merge the project_1_v2 branch into the project_1_v1 branch.
git merge project_1_v2
If there is a conflict at this time, you need to resolve the conflict. After the conflict is resolved, you can push it to the server.

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.