What are the differences between these git diff commands?

前端 未结 5 1232
执念已碎
执念已碎 2020-12-12 09:59

What are the differences between the following git commands?

  1. git diff HEAD
  2. git diff HEAD^
  3. git diff --cached
5条回答
  •  天涯浪人
    2020-12-12 10:45

    1. git diff HEAD : Diff between HEAD and the working directory.
    2. git diff HEAD^ : Diff between the direct ancestor of HEAD and the working directory.
    3. git diff --cached or the synonym git diff --staged : Diff between HEAD and the index.
    4. git diff : Diff between the index and the working directory.

提交回复
热议问题