/ GIT

Using git stash with a message

“What's in a name? That which we call a rose by any other name would smell just as sweet.” — William Shakespeare

Well, sometimes it's necessary.

As a developer we usually work on different branches or we need to switch branches. Sometimes we need to abandon some changes.

That's where git stash comes in picture. This is how the stash list looks like:

Using git stash without message

$ git shash list

stash@{0}: WIP on feature/1005-integration: 22454f23 Configure devise
stash@{1}: WIP on feature/1005-integration: 22454f23 Configure devise
stash@{2}: WIP on feature/1005-integration: 22454f23 Configure devise
stash@{3}: WIP On feature/1330-js-fix: 947a9c8d Fix js
stash@{4}: WIP on feature/1126-locale: 197a098d Fix test cases

Now the problem is if we have stashed changes multiple times git shows the message from last git commit. It's not helpful if we have lots of changes.

With the current way we will have to check the content using git show stash@{0}

Using git stash with message

$ git shash -m "Color theme changes in main.css"
# OR
$ git stash save "Color theme changes in main.css"

$ git stash list

stash@{0}: WIP on feature/1005-integration: Color theme changes in main.css
stash@{1}: WIP on feature/1005-integration: Javascript changes for theme
With the current approach we know exactly what a specific stash consists of: