git: Why doesn't git diff show any differences?

后端 未结 3 703
猫巷女王i
猫巷女王i 2021-02-06 21:03

If I run \'git status\' on my repo it gives:

# On branch master
# Changes to be committed:
#   (use \"git reset HEAD ...\" to unstage)
#
#   modified         


        
3条回答
  •  面向向阳花
    2021-02-06 21:35

    I have a preference for the --staged alias, mostly because I find that --staged actually means what I want to do, i.e. show me the staged differences.

    git diff --staged
    

    The accepted answer is correct and I have no qualms with it. Just personally think that --cached feels like git diff is caching the answer and showing me pre-calculated results or something.

    I also like git diff HEAD because it's a more general. It puts together two concepts that most folks know, that is:

    1. git diff allows you to see the difference between your current position and a previous commit.

    2. HEAD (or head because holding shift is annoying) is a reference to the tip of your branch. (For those of you who are counting keystrokes, @ is an alias for HEAD.)

    Combined, these two generally useful concepts result in:

    git diff head
    git diff @
    

提交回复
热议问题