Git merge 解决冲突
如何在命令行用 git mergetool 处理冲突
- git merge git checkout -b about master
- 编辑about.html git add about.html git commit -m "add about.html " git branch about2 about
- 编辑about.html git commit -m "add about.html 1" -a git checkout about2
- 编辑about.html git commit -m "add about.html 2" -a git checkout about git merge about2 git mergetool git commit
- 处理冲突软件(kdiff3):git config --global merge.tool kdiff3
- git mergetool
相关的软件是BeyondCompare
解决完冲突 commit 再push即可
当目录merge出现confilct时
可以使用git ls-files -s查看当前staged的object的状态
可以看到test文件出现了3个stage的状态,分别为1,2,3。
而没有出现冲突的文件的stage状态为0.
针对存在confilict的文件可以:
git show :1:test # 查看冲突文件的common ancester版本
git show :2:test # 查看本地branch中的版本
git show :3:test # 查看远程branch中的版本
参考文档:
https://www.yiibai.com/git/git_mergetool.html