Git merges two remote libraries

Source: Internet
Author: User

Tagged with: git two projects merged merge

Environment:
1. The local is empty, nothing at all
2. There are 2 different projects (works) on the remote Git
3. The need to merge these 2 projects locally
Start:
1. From the remote clone the first project code down, and switch to the branch you want to merge.
git clone [email protected]/project_1.git  //This operation will be built in a local project_1 folder, which is the code of Project 1. CD Project_1git Checkout PROJECT_1_V1  //This operation will switch the code to the PROJECT_1_V1 branch.
2. From the remote clone the second project code down and switch to the branch you want to merge.
git clone [email protected]/project_2.git  //This operation will be built in 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 stand in the project_1 angle, want to merge Project_2 's code into project_1. So, we go into 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. Fetching data from Project_2 warehouse to this warehouse
git fetch Other
6. Take the PROJECT_2_V1 branch from the Project_2 warehouse as a new branch checkout to local, with the new branch name set to PROJECT_1_V2
git checkout-b project_1_v2 other/project_2_v1
7. Now we stand in the PROJECT_1_V1 angle, want to merge project_1_v2 into PROJECT_1_V1 (because PROJECT_1_V2 is from project_2), so we want to switch to PROJECT_1_V1 branch.
git checkout Project_1_v1
8. Merge the PROJECT_1_V2 branches 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 and then push to the server after resolving the conflict.

Git merges two remote libraries

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.