为什么 git stash 创建两个提交

Why git stash creates two commits

这是一个使用 git log --graph --all refs/stash:

存储引用的历史图表
*   commit e5e6f3db57db6237a4334dc69a9a229f1cd7bd82 (refs/stash)
|\  Merge: 2a1a05a e918d31
| | Author: user <xxx@yyy.com>
| | Date:   Sun Jan 12 12:27:13 2020 +0000
| | 
| |     On master: some stash comment
| | 
| * commit e918d315535c6c6ade2dfb0538039d527dd0cd6e
|/  Author: user <xxx@yyy.com>
|   Date:   Sun Jan 12 12:27:13 2020 +0000
|   
|       index on master: 2a1a05a init
| 
* commit 2a1a05a258d3877ed1f6d32dfd57ae1941530418 (HEAD -> master)
  Author: user <xxx@yyy.com>
  Date:   Sun Jan 12 12:09:51 2020 +0000

      init

为什么需要提交 e5e6

看起来像regular stash commit

A stash entry is represented as a commit whose tree records the state of the working directory, and its first parent is the commit at HEAD when the entry was created.
The tree of the second parent records the state of the index when the entry is made, and it is made a child of the HEAD commit.

The ancestry graph looks like this:

       .----W
      /    /
-----H----I

where H is the HEAD commit, I is a commit that records the state of the index, and W is a commit that records the state of the working tree.

torek in " 所述

the stash entry represented by commit W and commit I, but W suffices to find I.
Either of W or I suffices to find H, and git stash will find all three commits automatically.

另见