在做項目工作的時候,同事修改了代碼一個cpp代碼,我同樣也修改了代碼,兩人代碼沖突了,提交之后,他代碼git自動合並,並提示: [master| MERGEING]
$ git merge my_new_branch
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
又或者提示如下錯誤:
Auto-merging src/ui/menu/wizardGroup.c
Auto-merging src/ui/menu/drawmenu5.c
Auto-merging src/ui/menu/drawmenu3.c
Auto-merging src/ui/menu/drawmenu2.c
Auto-merging src/ui/menu/drawmenu1.c
Auto-merging src/ui/menu/drawmenu0.c
Auto-merging src/string/language_d.h
CONFLICT (content): Merge conflict in src/string/language_d.h
Auto-merging src/string/languageDict.h
CONFLICT (content): Merge conflict in src/string/languageDict.h
Auto-merging src/drawui.c
Auto-merging src/dev/dev_phascan.c
Auto-merging src/dev/dev_flexscan.c
Auto-merging src/callback.c
Automatic merge failed; fix conflicts and then commit the result.
* 解決方法:
If you have fixed the conflicts you need to add the files to the stage with git add [filename], then commit as normal.
就是你手動修改git提示有錯誤的文件,修改之后,添加有沖突的文件: git add [被修改的沖突文件], 最后,按照普通提交那樣,提交有沖突的問題: git commit [修改后的沖突文件] -m “注釋內容”
*簡單的來說就是:
用git diff或者git status 查看哪些文件沖突,有沖突的會提示:
++<<<<<<< HEAD
++<<<<<<< new_branch
修改你的沖突的文件,修改完之后,保存。
用git add xxx,把你修改的文件全部都添加進去。
最后,用git commit -a -m ” 備注信息 ” 提交,完成。