Git merges two remote libraries __git

Source: Internet
Author: User
Tags git clone

Environment:
1. The local is empty, there is nothing
2. There are 2 different projects (works), on the remote Git
3. The need to merge the 2 projects locally
Start:
1. From the remote clone first project code down and switch to the branch you want to merge.

git clone git@xxx.com/project_1.git  //This operation will build a project_1 folder locally, which is the code for item 1.
CD project_1
git checkout project_1_v1  //This operation will switch the code to the PROJECT_1_V1 branch.
2. From the remote clone of the second project code down and switch to the branch you want to merge.
git clone git@xxx.com/project_2.git  //This operation will build a project_2 folder locally, which is the code for item 2.
CD project_2
git checkout project_2_v1  //This operation will switch the code to the PROJECT_2_V1 branch.
3. If we stand at the project_1 point of view, we want to merge project_2 code into project_1. So we go into the project_1
CD project_1
4. Project_2 as a remote repository, add to Project_1, set 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 from the Project_2 warehouse will be crawled as a new branch checkout to the local, with the new branch name set to PROJECT_1_V2
git checkout-b project_1_v2 other/project_2_v1
7. Now we are standing 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 have 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 point, the conflict needs to be resolved and the conflict can be pushed 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.