Skip to content

Instantly share code, notes, and snippets.

@martin-mok
Forked from Preethi-Dev/git__stash__commands.md
Created November 13, 2023 15:43
Show Gist options
  • Save martin-mok/fc0ab7e2c59140c1fbde7c56095f3373 to your computer and use it in GitHub Desktop.
Save martin-mok/fc0ab7e2c59140c1fbde7c56095f3373 to your computer and use it in GitHub Desktop.
Cheat sheet for git stash commands

Stash the changes

  1. git stash
  2. git stash save

Stash the untracked files

  1. git stash --include-untracked
  2. git stash -u

List the stashes

  1. git stash list

show the latest stash

  1. git stash show
  2. git stash show -p
  3. git stash show -u
  4. git stash show --include-untracked
  5. git stash show -p -u
  6. git stash show -p --only-untracked

Show the individual stash

  1. git stash show stash@{1}
  2. git stash show stash@{1} -p
  3. git stash show stash@{1} -u
  4. git stash show stash@{1} --include-untracked
  5. git stash show stash@{1} --only-untracked

Apply the stash

  1. git stash pop
  2. git stash apply
  3. git stash apply stash@{1}

Delete the stash

  1. git stash clear
  2. git stash drop stash@{2}

Create branch from stash

  1. git stash branch <branch_name>
  2. git stash branch <branch_name> stash@{revision}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment