作为码农,如果才能方便对git所管理的仓库的文件进行比较、合并已经可以作为程序员的软技能之一,一个好的工具和环境,不仅能够提高工作效率,更加能够身心愉悦。 话不多说,正如题 所说,这里为题提供一个思路,仅供参考
安装git
$ brew install git
安装 beyond compare
请前往Byeond Compare 官网,下载(MAC)对应平台的程序,安装
安装命令行工具
打开Beyond compare工具,然后依次点击右上角菜单 “Beyond compare” —>“Install Command Line Tools…"
修改 .gitconfig
在当前用户目录下创建或者修改.gitconfig文件,内容如下
[user]
name = xxx@github.com
email = xxx
[core]
excludesfile = /Users/allan/.gitignore_global
[diff]
tool = bcomp
[difftool]
prompt = false
[difftool "bcomp"]
trustExitCode = true
cmd = "/usr/local/bin/bcomp" \"$LOCAL\" \"$REMOTE\"
[alias]
diffall = diffall-org --copy-back
co = checkout
[merge]
tool = bcomp
[mergetool]
prompt = false
[mergetool "bcomp"]
trustExitCode = true
cmd = "/usr/local/bin/bcomp" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[commit]
template = /Users/allan/.stCommitMsg
配置git diffall 方便开发者使用
$ git clone https://github.com/thenigan/git-diffall
$ cd git-diffall
$ cp git-diffall $(git --exec-path)
[alias]
diffall = diffall-org --copy-back
co = checkout
使用说明
这样你就可以执行下列命令
$ git diffall //可以查看,修改,撤退对当前仓库里文件的改动
$ git diffall commit-id //.可以和某一次提交进行对比
$ git diffall stash@{0} //可以和本地暂存的修改进行对比。
参考:
- https://www.scootersoftware.com/support.php?zz=kb_vcs_osx
- https://github.com/thenigan/git-diffall
- https://git-scm.com/download/mac
|