Git Diff 差异分析

虽然命名交 Git diff 但是实际上 diff 可以是一个单独的工具,专门用来进行 文本比较

diff 是Linux 自带的命令,同样 git 中也集成了这个命令

命令格式:

diff <参数> <文件1或目录1> <文件2或目录2>

详情可以参考 菜鸟教程—Linux diff 或者参考 博客园中的信息

git 的 diff

  1. git diff 比较
  2. git diff --cached //省略HEAD HEAD与暂存区比较
  3. git diff //工作区 与暂存区 比较
  4. =diff --git a/ b/
  5. 假定:HEAD、缓存区、工作区中的readme.md文件内容均不相同。
  6. git diff HEAD -- readme.md //工作区 <===> HEAD
  7. git diff -- readme.md //工作区 <===> 缓存区
  8. git diff --cached -- readme.md //缓存区 <===> HEAD
  9. git diff <branch_name1> <branch_name2> -- <file_name> //分支 指定文件 比较

具体可以参考 Git-diff