概述:
在用git進行源代碼版本維護的時候,常常會進行各代碼版本之前區別的查看,例如在每次提交改動前進行git diff 可以看到源文件代碼相對相應版本或是遠程倉庫的改動情況,如果有沖突還需要進行merge即整合改動的代碼到指定版本(例如遠程分支)
安裝:
自己百度,安裝完成在C:\Program Files\SourceGear\Common\DiffMerge里面有相關的文檔介紹 。
Git配置:
找到git的 .gitconfig 文件,打開在里面添加下面這段。(sgdm的地址填你們自己的,但一般DiffMerge按默認是C:\Program Files\SourceGear\Common\DiffMerge)
[diff] cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' -merge -result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" |
添加之后實際的
常用的命令:
1、git difftool [fileName]
2、git mergetool [fileName]
merge某個分支的時候存在沖突
$ git merge feature1 Auto-merging readme.txt CONFLICT (content): Merge conflict in readme.txt Automatic merge failed; fix conflicts and then commit the result.
Git告訴我們,readme.txt文件存在沖突,必須手動解決沖突后再提交。git status也可以告訴我們沖突的文件:
$ git status # On branch master# Your branch is ahead of 'origin/master' by 2 commits.## Unmerged paths:# (use "git add/rm <file>..." as appropriate to mark resolution)##
both modified: readme.txt# no changes added to commit (use "git add" and/or "git commit -a")
我們可以直接查看readme.txt的內容:
Git is a distributed version control system. Git is free software distributed under the GPL. Git has a mutable index called stage. Git tracks changes of files. <<<<<<< HEAD Creating a new branch is quick & simple. ======= Creating a new branch is quick AND simple. >>>>>>> feature1
Git用<<<<<<<,=======,>>>>>>>標記出不同分支的內容,我們需要手動修改后保存
常見問題:
編碼:Tools--->options設置某類文件編碼