What is the difference between git diff HEAD vs. git diff --staged?

前端 未结 5 762
予麋鹿
予麋鹿 2021-01-29 19:18

What is the difference between git diff HEAD and git diff --staged? I tried both but both give the same output.

5条回答
  •  臣服心动
    2021-01-29 19:53

    • git diff View difference between Stage and Working Directory
    • git diff --staged View difference between HEAD and Stage
    • git diff HEAD View difference between HEAD and Working Directory


    img src


    img src

    • origin refers to the source repository from where it was cloned.
    • HEAD is a reference to the last commit in the currently checked-out branch.
    • Staged and index both are same
    • Unstaged changes exist in our Working Directory, but Git hasn’t recorded them into its version history yet.
    • Staged changes are a lot like unstaged changes, except that they’ve been marked to be committed the next time you run git commit

提交回复
热议问题