Back to TILs

TIL you can use git stash --patch (or -p) to interactively select which hunks to stash:

git stash -p

Git will show you each change and ask if you want to stash it. Super useful when you have mixed changes and only want to stash some of them.

Options at each hunk:

  • y - stash this hunk
  • n - don’t stash this hunk
  • s - split into smaller hunks
  • q - quit (stash what you’ve selected so far)