macOS中使用meld作为git mergetool和difftool
来源:互联网 发布:h3c 多个端口删除vlan 编辑:程序博客网 时间:2024/06/16 05:41
本文介绍通过下载meld应用的方式进行配置的过程,不适用于命令行安装的形式。
(命令行安装:brew install caskroom/cask/meld,之后自行尝试…)
meld for OSX:3.16.0
git:2.11.0
mergetool的选择
参考下文:
https://www.slant.co/topics/1324/~diff-tools-for-git
meld截图:
meld下载
meld官方不支持OSX,不过有第三方支持了
https://yousseb.github.io/meld/
meld配置
vi ~/.gitconfig
添加如下内容(确保原来不存在相同项)
[diff] tool = meld[difftool] prompt = false[difftool "meld"] trustExitCode = true cmd = open -W -a Meld --args \"$LOCAL\" \"$PWD/$REMOTE\"[merge] tool = meld[mergetool] prompt = false[mergetool "meld"] trustExitCode = true cmd = open -W -a Meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\"
可将上面最后一行中第二个参数 $BASE 改成 $MERGED,弄不清还是别改。
它们之间的差别:
$LOCAL is the file in the current branch .
$REMOTE is the file in the branch being merged .
$MERGED is the partially merged file with the merge conflict information in it.
$BASE is the shared commit ancestor of $LOCAL and $REMOTE.
meld使用
之后当冲突发生时,可以使用 git mergetool
来自动调用meld了
meld的操作非常简单,点点点之后save,然后关掉就可以了。
git difftool
和 git diff
用法相同
(我遇到了直接使用git difftool不会调用外部工具而使用git diff的情况,后来自己好了..)
不过合并完的时候会发现多了一个untracked文件 *.orig,这是mergetool自动产生的备份文件,保存了合并前的冲突状态下的文件。
如果想禁止自动备份,可以使用 git config --global mergetool.keepBackup false
或者在~/.gitconfig中的[mergetool]下添加
keepBackup = false
效果一样。
如果在meld中不想合并了,可以close without saving,然后git会问你 Was the merge successful? [y/n]
选择n,文件仍会保持冲突状态
选择y,文件会变成合并完成状态
如果文件已经是合并完成状态,又后悔了,那么可以使用自动备份的*.orig来恢复成冲突状态
如果想放弃整次合并,回到pull之前的状态,可以使用 git merge --abort
顺带一提,
.gitconfig中使用#可以注释该行
参考文章
http://stackoverflow.com/questions/34119866/setting-up-and-using-meld-as-your-git-difftool-and-mergetool/34119867#34119867
http://stackoverflow.com/questions/7711727/avoid-orphaned-orig-files-after-resolving-conflicts-from-a-git-merge
- macOS中使用meld作为git mergetool和difftool
- git difftool和mergetool图形化
- 用Beyond Compare代替git的difftool和mergetool
- 用Beyond Compare代替git的difftool和mergetool
- git mergetool 设置为 meld
- Windows下Git使用Winmerge作为difftool
- windows下使用winmerge作为git difftool
- git中配置Beyond Compare作为mergetool
- 使用Beyond Compare作为git mergetool的默认对比工具
- Mac安装Meld,并使用Meld作为git merge tool的工具
- 冲突杀手meld -- git使用meld作为对比或合并工具_zhou
- 配置WinMerge作为Git的mergetool
- git mergetool
- git difftool bcompare
- git difftool for mac
- Mac下使用git difftool来做代码比较
- 使用meld做git的diff工具
- git使用meld查看文件修改内容
- Ubuntu 16.10 搜狗不能输入中文
- svn钩子(hooks)
- linux下java高内存故障排查
- web的学习笔记一
- 62. Unique Paths
- macOS中使用meld作为git mergetool和difftool
- git简单使用
- spring-mvc基本架构-2
- JVM内存管理------垃圾搜集器参数精解
- 外边距塌陷之clearance
- pat甲级1009. Product of Polynomials (25)
- 转换流(字符) 带缓冲的字符流 FileReader(字符流)
- 博客搬迁
- java 异常处理