如何解决Gitee提交pr冲突 |
您所在的位置:网站首页 › pr出现事件怎么解决 › 如何解决Gitee提交pr冲突 |
下面以system_cpu_probe冲突为例,介绍解决冲突的流程。 因为创建、合并和删除分支非常快,所以Git鼓励你使用分支完成某个任务,合并后再删掉分支,这和直接在master分支上工作效果是一样的,但过程更安全。 以下步骤,均在本地master分支(即提交Pr的分支)进行。 当然,为安全起见,可以新开一个分支,在此之上进行操作。但后续需要合并(merge)到master分支,再提交,详情可参考廖雪峰的blog:解决冲突。 如果只有一个commit,直接跳到第2步。否则:先尝试合并所有提交的commit为一个,如果不行,查看日志,回退到最初的版本。回退前,保存好后面提交commit的相关改动。 [root@localhost A-Ops]# git log [root@localhost A-Ops]# git reset --hard 尝试同步远程分支 [root@localhost A-Ops]# git fetch upstream [root@localhost A-Ops]# git rebase upstream/master Auto-merging gala-gopher/src/probes/system_infos.probe/system_cpu.c CONFLICT (content): Merge conflict in gala-gopher/src/probes/system_infos.probe/system_cpu.c error: could not apply 0d8ab09... system cpu probe: add 2 metrics, and make some modifications Resolve all conflicts manually, mark them as resolved with "git add/rm ", then run "git rebase --continue". You can instead skip this commit: run "git rebase --skip". To abort and get back to the state before "git rebase", run "git rebase --abort". Could not apply 0d8ab09... system cpu probe: add 2 metrics, and make some modifications可以看到,在与远程分支自动合并gala-gopher/src/probes/system_infos.probe/system_cpu.c时,发生冲突,需要手动解决。在此之后,还需要执行git add/rm ,git rebase --continue。 如果中途遇到任何rebase误操作,可以执行git rebase --bort终止这次rebase。 进入冲突的文件,手动修复冲突 [root@localhost A-Ops]# vim gala-gopher/src/probes/system_infos.probe/system_cpu.c![]() |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |