关于git的差异
我之前一直使用svn来管理程序,但是当我开始开发和验证时,我发现使用git来管理验证阶段的文件以及回到先前的环境非常方便。我想总结一下我对git diff确认的使用体验。
git的改动对比
由于git diff命令可以在上下方向上输出变更前后的差异,因此我们通常使用git diff来确认小规模的变更。
// ワーキングエリアでの比較
$ git diff
// ファイルのみ
$ git diff --name-only
// ステージング上での比較
$ git diff --cached
// commitした者同士
$ git diff 変更前のSHA..変更後のSHA
git的差异工具
在git上设定默认使用的差异工具,并使用该工具来确认差异。差异工具的设定写在.gitconfig文件中并进行使用。因为我使用的是Windows系统,所以我使用WinMerge作为差异工具来确认存放在工作区的文件。设定方法已经在这篇文章中写出来了。
使用WinMerge可以显示修改过的目录和文件的差异,并且以并排的方式展示差异,这样查看起来非常方便和实用。
$ git difftool -h
usage: git difftool [<options>] [<commit> [<commit>]] [--] [<path>...]
-g, --gui use `diff.guitool` instead of `diff.tool`
-d, --dir-diff perform a full-directory diff
-y, --no-prompt do not prompt before launching a diff tool
--symlinks use symlinks in dir-diff mode
-t, --tool <tool> use the specified diff tool
--tool-help print a list of diff tools that may be used with `--tool`
--trust-exit-code make 'git-difftool' exit when an invoked diff tool returns a non-zero exit code
-x, --extcmd <command>
specify a custom command for viewing diffs
--no-index passed to `diff`