The actual data stashed by "git stash
" (i.e. the current version of the working tree and the contents of .git/index
) is stored as two commit trees.
One commit tree contains a snapshot of the current state of the working tree. There are some tricky bits here, see below.
The other commit tree, I've been told, is used to store a snapshot of the contents of .git/index
at the time of the stash. I haven't looked into this deeply enough (yet) to understand how the one is translated into the other.
.git/refs/stash
contains the hash value for the commit tree that the stash created.
.git/logs/refs/stash
contains a reflog-like chunk of metadata about the stashes before the one in .git/refs/stash
.
.git/index
holds a list of entries for each file in the working tree. Those entries contain the full path and filename and also cached metadata about the file, both filesystem metadata and git-related metadata.
"git add
" both add a copy of a file to the object store, and sets the staging flag for that file in .git/index.
For "git stash
" to create a commit tree, files that have been changed (edited) but not yet staged with "git add
" have to be added to the object store. "git stash
" does this by building a temporary index file.