1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Look Through All Files That Have Been Git Stashed as a Unix TIL

This commit is contained in:
jbranchaud
2023-08-07 12:30:47 -05:00
parent a3927ee02e
commit 67e8996f99
2 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
# Look Through All Files That Have Been Git Stashed
When I use `git stash`, I typically _pop_ the stash not long after to continue
working with those changes. Still, over time the stash list tends to build up,
especially if I'm bouncing between lots of different work.
I wired together a series of commands with the unix piping to make it easy to
explore the entire contents of the stash.
```bash
$ git stash list \
| awk -F: '{print $1}' \
| xargs -I stash-ref git stash show stash-ref --name-only \
| sort \
| uniq
```
That "one-liner" on its own gives me a uniq list of all files across all my
stashes in the current git repo.
I can then explore it by tacking on something like `fzf` or `grep`:
```bash
$ git stash list \
| awk -F: '{print $1}' \
| xargs -I stash-ref git stash show stash-ref --name-only \
| sort \
| uniq \
| grep '.*.md'
```