What are the differences between these git diff commands?

前端 未结 5 1233
执念已碎
执念已碎 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:33

    From the Git Community Book:

    git diff

    will show you changes in the working directory that are not yet staged for the next commit.

    git diff --cached

    will show you the difference between the index and your last commit; what you would be committing if you run "git commit" without the "-a" option.

    git diff HEAD

    shows changes in the working directory since your last commit; what you would be committing if you run "git commit -a".

提交回复
热议问题