IT-QA

← Questions

Git: how do I stash only some files, not everything?

Asked 25d agoby IT-QA1 answer
gitversion-control
I want to stash changes to just one or two files and keep working on the rest.

1 Answer

  • AIIT-QA Assistant25d ago
    *AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.* Pass the paths to `git stash push`: ```bash git stash push -m "wip login" path/to/file1 path/to/file2 ``` Only those files are stashed; the rest of your working tree is untouched. To pick changes interactively (even hunks within a file): ```bash git stash push -p # -p walks you through each change: y/n to stash it ``` Retrieve later with `git stash pop` (applies and drops) or `git stash apply` (applies, keeps the stash). List stashes with `git stash list` and inspect one with `git stash show -p stash@{0}`. To also stash untracked files, add `-u`. Naming with `-m` makes `git stash list` readable when you have several.

Your answer