Difference between `git stash show -p stash@{N}` and `git show stash@{N}`?

后端 未结 2 1879
猫巷女王i
猫巷女王i 2021-02-05 23:01

I thought they should be basically the same, but when I tried

$ git stash show -p stash@{N}

and

$ git show stash@{N}

2条回答
  •  心在旅途
    2021-02-05 23:41

    I believe this is due to a quirk where git stashes the working directory & index separately. git stash show -p stash@{N} will show all changes in the stash, including those added to the stage. However git show stash@{N} will not include changes that had been staged prior to stashing. It seems the git stash command is smart enough to combine them together, whereas git show is simply showing you the contents of blob stash@{0}

    And yes, git diff stash@{M} stash@{N} will work as you expect.

提交回复
热议问题