DEV Community

Joe Purnell
Joe Purnell

Posted on

Git Stash - A Personal Reminder

I got Déjà vu again - I was searching on a popular search engine for a command to help me stash my changes in a certain way, I felt like I had been here before. Google confirmed this by displaying a familiar purple text colour showing me I had indeed visited this page before.

So I decided to make a quick note to myself (and for any others who may stumble upon this post), at least I'll be giving myself post views when I inevitably forgot these commands and need to look them up again.

This is not meant to be an in-depth analysis or rundown of the full git stash CLI, you can find that here.

This is simply to serve as a reminder of those commands I find myself needing from time to time.

Simple and classic - Stash your changes

git stash

Add a message to your stash

git stash --save "Super descriptive message goes here"

You can include untracked files

git stash --include-untracked

# Or a bit shorter
git stash -u

When you want to stash everything apart from staged changes

git stash --keep-index

# Save those keys

git stash -k

Have a look at your stashes

git stash list

Apply the last stashed change and remove it from your stash list

git stash pop

Apply the last stash change but keep it in the list as a stash (for some reason)

git stash apply

Clear up after yourself and remove all stashes

git stash clear

Top comments (0)