Last Updated: February 25, 2016
·
823
· leostatic

Faster Git Stash

Git Stash is so very useful when you are working on multiple stuff across multiple branches. Sadly, the commands are just too verbose. Here's a simple bash function to make it faster

##making git stash faster to use
# gst       -- lists all the stashes
# gst c     -- creates a new stash
# gst a 0   -- applies stash number 0
# gst d 0   -- [CAREFUL] drops stash number 0

function gst() {
    if [ -z "$1" ]; then        
        git stash list
    elif [ "$1" == "a" ]; then
        git stash apply stash@{"$2"}
    elif [ "$1" == "c"  ]; then
        git stash 
    elif [ "$1" == "d" ]; then
        git stash drop stash@{"$2"}
    fi
}

Stick it in your .bash_aliases and you are good to go!