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