![Forrest logo](/images/logo.png)
git-stash:tldr:f3245
The git stash -p
command is used to interactively select parts of modified files to be stashed away in temporary storage called "stash" in Git.
The -p
option stands for "patch" and allows you to review and choose specific changes or lines from the modified files that you want to stash. It initiates an interactive mode called the patch mode.
When you run git stash -p
, Git will present you with a series of prompts for each hunk (a distinct section of changes) in the modified files. You can choose to apply or skip each hunk by entering specific commands. Here are some common commands used in the patch mode:
y
orn
: Apply the current hunk or skip it.s
ore
: Split the current hunk into smaller hunks to allow more granular selection.?
: Display help information on available commands.q
: Quit the patch mode without stashing any changes.a
: Apply all remaining hunks without further prompts.d
: Do not stash any of the remaining hunks.
By using the git stash -p
command, you have more control over the specific changes you want to temporarily store in the stash rather than stashing the entire set of modifications.