概述:
在用git进行源代码版本维护的时候,常常会进行各代码版本之前区别的查看,例如在每次提交改动前进行git diff 可以看到源文件代码相对相应版本或是远程仓库的改动情况,如果有冲突还需要进行merge即整合改动的代码到指定版本(例如远程分支)
安装:
自己百度,安装完成在C:Program FilesSourceGearCommonDiffMerge里面有相关的文档介绍 。
Git配置:
找到git的 .gitconfig 文件,打开在里面添加下面这段。(sgdm的地址填你们自己的,但一般DiffMerge按默认是C:Program FilesSourceGearCommonDiffMerge)
[diff] tool = diffmerge[difftool “diffmerge”] cmd = C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe ”$LOCAL” ”$REMOTE” [merge] tool = diffmerge[mergetool “diffmerge”] trustExitCode = true cmd = ‘C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe’ -merge -result=”$MERGED” ”$LOCAL” ”$BASE” ”$REMOTE” |
---|
添加之后实际的
常用的命令:
1、git difftool [fileName] 2、git mergetool [fileName]
merge某个分支的时候存在冲突
代码语言:javascript复制$ 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也可以告诉我们冲突的文件:
代码语言:javascript复制$ 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的内容:
代码语言:javascript复制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设置某类文件编码
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/168162.html原文链接:https://javaforall.cn