Is it possible to search through Git stash items?

There are some helpful ideas in this Gist and discussion thread.

First, just listing matching stashes is easy (with or without -i, depending if case matters)

git stash list -i -G<regexp>

If there’s not that much to dig through, you can just add -p to print the matching stashes in their entirety.

git stash list -i -p -G<regexp>

With more power for “real” cases, add it to .gitconfig:

[alias]
    stashgrep = "!f() { for i in `git stash list --format=\"%gd\"` ; \
              do git stash show -p $i | grep -H --label=\"$i\" \"$@\" ; done ; }; f"

and then you can call git stashgrep with any grep arguments you like (-w, -i). e.g.,

git stashgrep -i <regexp>

This differs from some answers above, in that it prepends the stash ID to show you where each difference came from:

% git stashgrep -i tooltip
stash@{5}: //            resetBatchActionTooltip();
stash@{5}:         addAcceleratorsAndTooltips(lToolMenu, lToolButton, iListener, iTool);
stash@{5}:     private void addAcceleratorsAndTooltips(AbstractButton lToolMenu,
stash@{5}:+        String lToolTip = iTool.getToolTipText();
stash@{5}:             lToolButton.setToolTipText(lToolTip);
stash@{20}:+    private static final String invalidSelectionTooltip = "Invalid selection.  Please choose another.";
stash@{20}:-    private final String invalidSelectionTooltip = "Invalid selection.  Please choose another.";
stash@{20}:                         ((JTextField)lComponent).setToolTipText(

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)