Merging two git warehouses

Time:2020-11-27

Now there are two warehouses, kktjs / KKT and kktjs / KKT nextkkt-nextWarehouse merge tokktAnd keep itkkt-nextAll submissions for.

#1. Clone the main warehouse code
git clone [email protected]:kktjs/kkt.git
#2. Add KKT next as a remote warehouse to KKT, and set the alias as other
git remote add other [email protected]:kktjs/kkt-next.git
#3. Pull data from KKT next warehouse to this warehouse
git fetch other
#4. Check out the master branch pulled from the KKT next warehouse as a new branch, and set the name of the new branch as KKT next
git checkout -b kkt-next other/master
#5. Switch back to the master branch of KKT
git checkout master
#6. Merge KKT next into the master branch of KKT
git merge kkt-next
#If an error is reported in step 6, fatal: referring to merge unrelated histories`
#Please carry out the following command
git merge kkt-next --allow-unrelated-histories

When merging, it is possible that the two branches have made changes to the same file. In this case, the conflict needs to be resolved. For text files, it is very simple, and the conflict location can be processed as required. For binary files, you need to use the following command:

git checkout --theirs YOUR_ BINARY_ Files ා preserves changes to branches that need to be merged
git checkout --ours YOUR_ BINARY_ Files ා keep your own changes
git add YOUR_BINARY_FILES