TIL - Named Git Stash

You can name a git stash like so:

git stash push -m "message"

Thwn find it like so:

git stash list

And apply the specific stash like so:

git stash apply stash@{1}

However git diff may be a better solution

git diff > some.patch

And to apply

git apply some.patch

So I’ve added these to my shell aliases .

# Store patch
function gdsp() {
    git diff > ~/.stashes/$1.patch
    gdlp
}

# Apply patch
function gdap() {
    git apply ~/.stashes/$1.patch
    rm ~/.stashes/$1.patch
    gdlp
}

# List patches
function gdlp() {
    ls ~/.stashes/
}
Proud member of Hotline Webring