View Git Stash Contents Without Applying to Codebase

Snippet

Use git stash list to view all stashes

Use git stash show with options to view a stash without applying it to the codebase.

# see a "git diff" of what's in the first stash 
git stash show -p stash@{0}

And, a shell script to view these. Save this into a file, chmod +x the file, and run in the terminal.

#!/bin/bash
 
readonly STASH="$1"
 
if [[ "xx${STASH}" != "xx" ]]; then
    git stash show -p stash@{${STASH}}
else
    git stash list
fi

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.