12

I'm working on a huge git repository that is too large to make viewing all remote branches practical. Thus I don't want to use gitk --all. However, I do like to view other things like my local branches, which I can do with gitk --branches.

Is there a way to also view any stashes?

Jaap Eldering
  • 466
  • 6
  • 15
  • I recommend you adopt [my multi stash gitk patch](https://gist.github.com/uprego). **It won't remove the remote branches**, but at least it will show you all your stashes. I share a version for Debian Stretch, developed from a version for an old official rev, developed from a version for Debian Jessie that ultimately roots in Debian Wheezy. – 1737973 Oct 28 '18 at 23:54

1 Answers1

17

UPDATE with more concise log command...

You might notice that even with --all, gitk does not list all stashes. This is because stashes are not distinct refs; they are reflog entries on the single ref stash.

You can still list multiple stashes, such as by saying

gitk stash@{0} stash@{1}

but only the most recent stash commit will be shown as having a ref pointed at it (which is true; again, the rest are reflog entries).

To automatically include every stash, you can do something like this

gitk `git stash list --format=%H`

This may not help much, though, as a stash's full history would be shown. (And again, only the most recent stash would show with a ref pointed at it, so spotting the others in a long history might not be easy.)

With git log you could do something like

git log `git rev-parse $(git stash list --format=^%H^)` `git stash list --format=%H`

or, more concisely,

git log `git rev-parse $(git stash list --format=%H^..%H)`

to cut the history short and show only stash commits, but gitk doesn't seem inclined to honor the ^<commit> exclusions. Also -n 1 doesn't work because that limits the total number of commits output, not the number per ref (and besides, gitk then decides to be helpful by filling in the history anyway).

So I'm not entirely sure you can do what you want with gitk. But on the other and, the graph that gitk draws would just be a disjointed mess anyway, so maybe the log approach could be adapted to suit your needs?

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52
  • Thanks for the detailed explanation. However, running `gitk stash@{0}` is not quite what I'm looking for: it only shows the tree leading to the stash, while I'd like to see my (recent) stashes next to the current branch that I'm working on, and also that these would be updated when I refresh the gitk view. It seems that that is not possible... – Jaap Eldering Jan 17 '18 at 11:14