0

I'm using the following command to list all my commits:

git log --oneline --graph --decorate --all

This shows only one entry for my stashes. This entry is at the position of the the last commit from which I started a stash.

Is it also possible to show each stash at it parent commit?

Say I have the following git-log:

* 063b893 (HEAD, master) first commit
* 4e6efb9 initial commit

After adding a stash:

*   51eb834 (refs/stash) WIP on master: 063b893 first commit
|\  
| * dfafaaf index on master: 063b893 first commit
|/  
* 063b893 (HEAD, master) first commit
* 4e6efb9 initial commit

After adding a second stash (Problem 1: only the last stash is shown):

*   1e9b384 (refs/stash) WIP on master: 063b893 first commit
|\  
| * 4862a3d index on master: 063b893 first commit
|/  
* 063b893 (HEAD, master) first commit
* 4e6efb9 initial commit

After adding a second commit, stash is still show in the correct position:

* c09a3fc (HEAD, master) second commit
| *   1e9b384 (refs/stash) WIP on master: 063b893 first commit
| |\  
|/ /  
| * 4862a3d index on master: 063b893 first commit
|/  
* 063b893 first commit
* 4e6efb9 initial commit

After adding another stash and commit (Problem 2: stashes that were made directly after first commit are not shown. The only stash shown is after second commit):

* d86c140 (HEAD, master) third commit
| *   4efd3e0 (refs/stash) WIP on master: c09a3fc second commit
| |\  
|/ /  
| * 5065abe index on master: c09a3fc second commit
|/  
* c09a3fc second commit
* 063b893 first commit
* 4e6efb9 initial commit

I'd expected to see:

* d86c140 (HEAD, master) third commit
| *   4efd3e0 (refs/stash) WIP on master: c09a3fc second commit
| |\  
|/ /  
| * 5065abe index on master: c09a3fc second commit
|/  
* c09a3fc second commit
| *   1e9b384 (refs/stash) WIP on master: 063b893 first commit
| *   51eb834 (refs/stash) WIP on master: 063b893 first commit
| |\  
|/ /  
| * 4862a3d index on master: 063b893 first commit
|/  
* 063b893 first commit
* 4e6efb9 initial commit
SQB
  • 3,926
  • 2
  • 28
  • 49
Edward
  • 4,453
  • 8
  • 44
  • 82
  • The position from the last commit could be considered to be its parent. Could you post what that graph looks like and where you're confused? I would expect the stash ref to point to the position in history where I was at when I stashed my code. – Makoto Feb 18 '15 at 17:39

1 Answers1

0

The problem is that --all simply looks at all the references, and stash is exactly one reference, giving the (latest/current) stash.

Where are all the other stashes? They're hiding away in the refs/stash reflog. --all does not extract reflogs and --decorate does not examine reflogs.

You can get the other stashes to show up by calling them out explicitly:

git log --oneline --graph --decorate --all stash@{1} stash@{2}

(this assumes three total stashes, --all gets one and we add the other two here; it requires a little bit of scripting or similar to programmatically count stash reflog entries and add the appropriate number of stash@{n} items), but they won't get decorations.

torek
  • 448,244
  • 59
  • 642
  • 775