Stashing unstaged changes stashes everything#4993
Merged
ianhattendorf merged 4 commits intomainfrom Feb 26, 2026
Merged
Conversation
🤖 Augment PR SummarySummary: Fixes the SCM “Stash Unstaged Changes” flow so it no longer stashes/resets staged changes unexpectedly. Changes:
Technical Notes: The new Git workaround is scoped to the problematic 🤖 Was this summary useful? React with 👍 or 👎 |
This hits a bug in git: $ mkdir stash-test && cd stash-test && git init $ echo a > a.txt $ git add a.txt $ git commit -m init $ echo b > b.txt $ git stash push --keep-index --include-untracked -- b.txt Saved working directory and index state WIP on main: 8a280fe init error: pathspec ':(prefix:0)b.txt' did not match any file(s) known to git
1c5f135 to
2bc8cab
Compare
Contributor
Author
Contributor
Author
|
augment review |
2bc8cab to
26c110a
Compare
26c110a to
c8a92aa
Compare
eamodio
approved these changes
Feb 25, 2026
|
Did somebody confuse staged and untracked changes? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
There were actually two reasons why staged changes were being reset when attempting to stash unstaged changes from the SCM view.
Reason 1
When clicking
Stash Unstaged Changes...in the SCM view, we went through the full quick pick flow where we ask for confirmation and which flags to use.This caused the
--keep-indexarg to be dropped, resulting in staged changes being reset in the working directory.Now, we
don't ask for confirmationonly display one option when stashing unstaged changes from the SCM view.Reason 2
As a workaround for a git bug (#2784), we disallowed
--keep-indexalongside--include-untracked. We can make this more specific, to only disallow them together when using pathspecs.I will also open a bug report with git later, as the repro is trivial (see code comment).
Fixes #4503.