Git Diff 差异分析
虽然命名交 Git diff 但是实际上 diff 可以是一个单独的工具,专门用来进行 文本比较
diff 是Linux 自带的命令,同样 git 中也集成了这个命令
命令格式:
diff <参数> <文件1或目录1> <文件2或目录2>
详情可以参考 菜鸟教程—Linux diff 或者参考 博客园中的信息
git 的 diff
git diff 谁 与 谁 比较
git diff --cached //省略HEAD HEAD与暂存区比较
git diff //工作区 与暂存区 比较
=diff --git a/ b/
假定:HEAD、缓存区、工作区中的readme.md文件内容均不相同。
git diff HEAD -- readme.md //工作区 <===> HEAD
git diff -- readme.md //工作区 <===> 缓存区
git diff --cached -- readme.md //缓存区 <===> HEAD
git diff <branch_name1> <branch_name2> -- <file_name> //分支 指定文件 比较
具体可以参考 Git-diff