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.