Git 仓库之间的代码合并
背景:有两个仓库A、仓库B。想要合并仓库 A 中的某个分支到仓库 B 中的某个分支。假设要将仓库 A 的分支:dev_A 合并到仓库 B 的分支:dev_B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| 1. 进入仓库 B 的目录,切换到仓库 B 分支 dev_B 上 git checkout dev_B
2. 将仓库 A 的地址添加到仓库 B 中 git remote add 仓库名称 地址 如:git remote add jay_qapm_android_sdk git@git.woa.com:jaylin/RUM_SDK_Android.git jay_qapm_android_sdk git@git.woa.com:jaylin/RUM_SDK_Android.git (fetch) jay_qapm_android_sdk git@git.woa.com:jaylin/RUM_SDK_Android.git (push) origin git@git.woa.com:TAM/QAPM_SDK.git (fetch) origin git@git.woa.com:TAM/QAPM_SDK.git (push)
3. 查看本地的远程仓库 git remote -v
4. 抓取仓库 A 数据到仓库 B 中 git fetch 仓库名称 如:git fetch jay_qapm_android_sdk
5. 将仓库 A 的分支在仓库 B 中新建一个新分支 git checkout -b 新分支 仓库名称/仓库分支 如:git checkout -b temp_dev_A jay_qapm_android_sdk/dev_A
6. 然后切换到目的分支 git chekcout dev_B
7. 进行合并 git merge --no-ff temp_dev_A
|