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.