Skip to content

Stashing unstaged changes stashes everything#4993

Merged
ianhattendorf merged 4 commits intomainfrom
4503-stashing-unstaged-changes-stashes-everything
Feb 26, 2026
Merged

Stashing unstaged changes stashes everything#4993
ianhattendorf merged 4 commits intomainfrom
4503-stashing-unstaged-changes-stashes-everything

Conversation

@ianhattendorf
Copy link
Contributor

@ianhattendorf ianhattendorf commented Feb 20, 2026

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.

image

This caused the --keep-index arg to be dropped, resulting in staged changes being reset in the working directory.

Now, we don't ask for confirmation only display one option when stashing unstaged changes from the SCM view.

image

Reason 2

As a workaround for a git bug (#2784), we disallowed --keep-index alongside --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.

@augmentcode
Copy link

augmentcode bot commented Feb 20, 2026

🤖 Augment PR Summary

Summary: Fixes the SCM “Stash Unstaged Changes” flow so it no longer stashes/resets staged changes unexpectedly.

Changes:

  • Adds a singleConfirm mode to the stash-push quick wizard to show a single pre-determined confirmation choice for the SCM “unstaged” action.
  • Threads singleConfirm through stashSave → stash action → stash push command state.
  • Ensures the command-palette “unstaged” command resolves a repository and derives the correct flags before launching the wizard.
  • Refines the git stash push argument logic to only forbid --keep-index with --include-untracked when pathspecs are involved (workaround for a Git bug).
  • Updates the changelog entry for the fix.

Technical Notes: The new Git workaround is scoped to the problematic --keep-index --include-untracked -- <pathspec> combination to avoid regressing the “keep staged intact” behavior in other stash flows.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@ianhattendorf ianhattendorf marked this pull request as draft February 20, 2026 18:21
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
@ianhattendorf ianhattendorf force-pushed the 4503-stashing-unstaged-changes-stashes-everything branch from 1c5f135 to 2bc8cab Compare February 23, 2026 16:22
@ianhattendorf
Copy link
Contributor Author

Updated to keep the confirmation dialog, but only display one option (what we've detected we need to do) for unstaged changes.

image

It now also works for through the stash unstaged changes command palette command.

@ianhattendorf
Copy link
Contributor Author

augment review

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@ianhattendorf ianhattendorf force-pushed the 4503-stashing-unstaged-changes-stashes-everything branch from 2bc8cab to 26c110a Compare February 23, 2026 21:11
@ianhattendorf ianhattendorf marked this pull request as ready for review February 23, 2026 21:11
Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@ianhattendorf ianhattendorf force-pushed the 4503-stashing-unstaged-changes-stashes-everything branch from 26c110a to c8a92aa Compare February 23, 2026 22:02
@ianhattendorf ianhattendorf merged commit 0d42904 into main Feb 26, 2026
6 checks passed
@ianhattendorf ianhattendorf deleted the 4503-stashing-unstaged-changes-stashes-everything branch February 26, 2026 00:02
@AnrDaemon
Copy link

Did somebody confuse staged and untracked changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stashing unstaged changes stashes everything

3 participants