如何使用git命令进行分支同步
本篇讲述如何使用repo命令同步远程代码,更新到本地分支。使用场景为:同步平台发布代码,并更新到自己平台中。
- 下载代码
- 同步代码
- 寻找差异
- 同步到本项目
- 上传代码
下载代码
登陆服务器,创建代码目录,下载平台代码:
repo init -u ssh://git@1xx.xxx.xxx.xxx/platfrom/manifest -b b1 -m xxx.xml
同步代码
切换到平台分支:
repo forall -c git checkout plat
sync代码:
repy sync -c -j4
寻找差异
一般来说台提供脚本对比代码差异,运行后即可得出差异结果:
repo_tool.py –dir $(pwd) –xxxx xxxx xxxx
同步到本项目
切换到本项目分支:
git checkout our
merge差异点:
git merge plat
上传代码
git push zz –all && git push zz –tags