git合并两个分支及合并两个仓库

一、git合并两个分支

1.git checkout dev (切换到本地要合并的分支)
2.git pull (拉去最新代码)
3.git checkout master (切换到主分支)
4.git merge dev (合并分支)
5.git push origin master (将合并后的代码push到远程仓库)

二、git合并两个仓库(将grid-management-ui 的develop 合并到city-vue的zhumadian_dev)

1.git checkout zhumadian_dev (切换到本地zhumadian_dev分支)
2.git remote add 仓库名称 仓库地址 (将远程仓库添加到本地zhumadian_dev)
git remote add grid-management-ui ssh://git@xxx/grid-managem
3.git fetch grid-management-ui (从grid-management-ui仓库中抓取数据到本仓库,注意这里是上面设置的别名)
4.git checkout -b grid-management-ui_new grid-management-ui/develop (将ogrid-management-ui仓库抓取的develop分支作为新分支checkout到本地,新分支名设定为grid-management-ui_new)
5.git checkout zhumadian_dev (切换回本地测试的city-vue的zhumadian_dev)
6.git merge grid-management-ui_new --allow-unrelated-histories (将grid-management-ui_new合并入zhumadian_dev分支)
7.解决冲突并将代码提交到远程仓库


 

你可能感兴趣的:(git)