git多人协作代码合并流程

Git协作开发方式1:

1、git commit,提交修改到git 本地Cache中;

2、git pull --rebase origin branchname,通过rebase方式合并代码;

3、git push -u origin branchename,将所有修改提交到远端。

 

该方式适合于所有代码commit后,他人获取可以顺利编译运行的情况。

 

步骤2可能产生文件冲突。

例如:

Auto-merging products/xxx/res/ccb/Node.ccbi

CONFLICT (content): Merge conflict in products/xxx/res/ccb/Node.ccbi

修改方法为:

1)手工修改冲突文件;

2)用本地的或者他人的文件替换冲突文件。(注意:ours/theirs的实际作用与字面意义是相反的!!!

a、以本地文件为准:git checkout --theirs products/xxx/res/ccb/Node.ccbi。(The option will keep the original one we had.)

b、以他人提交文件为准:git checkout --ours products/xxx/res/ccb/Node.ccbi。(The option will keep the version of the file that you merged in.)

 

修复后,执行命令:

git add products/xxx/res/ccb/Node.ccbi

git rebase --continue

 

重复上述方法,一直到rebase结束。

中间如果存在以下情况

Applying: Fixed unit test

No changes - did you forget to use 'git add'? If there is nothing left to stage, chances are that something else already introduced the same changes; you might want to skip this patch.

When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".

这种情况,很可能是你修复 products/xxx/res/ccb/Node.ccbi 的方式为从别处拷贝,而不是手工修复冲突处,所以系统认为文件没有变化。解决方法如下:

执行命令:

git config --global core.trustctime false

 或者手工修改。参考文章

 

如果本地修暂时无法commit的话,则可以采取stash方式更新他人代码。

1、git stash --include-untracked

2、git pull --rebase origin branchname

3、git stash pop

4、修复可能存在的merge文件冲突。

 

采用git pull --rebase,而不是默认的git merge,请参考文章

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值