Repository navigation
Keep multiple stashes and stash checked files - #23275
Open
devcustrom wants to merge 1 commit into
Open
devcustrom wants to merge 1 commit into
devcustrom wants to merge 1 commit into
Conversation
Keep every Desktop stash entry for a branch instead of only the newest one, and show them as a list in the Changes sidebar. Each entry can be selected, viewed, restored, or discarded by its SHA. Stashing no longer overwrites the previous stash entry, so the overwrite confirmation dialogs and labels are gone. Branch renames move all stash entries for the branch. Also add a Stash Checked Changes action to the changes context menus which passes the checked files as literal pathspecs to git stash push.
devcustrom
requested review from
sergiou87
and
a balanced review from Copilot
December 3, 2026 09:08
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Restricted stashing can include unchecked staged files and leave checked rename deletions behind, while stash failures go unreported and leave the dialog stuck loading.
4 open issues
What changed in this PR
Extends GitHub Desktop’s branch-specific stashing to retain multiple entries and stash checked files, addressing the workflows described in #12699 and #11531.
Changes:
- Lists timestamped stashes and tracks selection by SHA.
- Adds checked-file stashing using literal pathspecs.
- Removes overwrite confirmations and preserves stashes during branch renaming.
| File | Description |
|---|---|
| app/test/unit/ui/stash-and-switch-branch-dialog-test.tsx | Updates dialog props. |
| app/test/unit/main-process/menu-test.ts | Removes obsolete confirmation flag. |
| app/test/unit/git/stash-test.ts | Adds timestamps to fixtures. |
| app/test/unit/git/stash-multi-test.ts | Tests multiple stashes and path filtering. |
| app/test/helpers/changes-state-helper.ts | Initializes stash collections. |
| app/styles/ui/changes/_changes-list.scss | Styles the stash list. |
| app/src/ui/stashing/stash-diff-viewer.tsx | Selects files within a specific stash. |
| app/src/ui/stash-changes/stash-and-switch-branch-dialog.tsx | Removes overwrite warnings. |
| app/src/ui/stash-changes/overwrite-stashed-changes-dialog.tsx | Deletes obsolete confirmation dialog. |
| app/src/ui/repository.tsx | Resolves the selected stash by SHA. |
| app/src/ui/local-changes-overwritten/local-changes-overwritten-dialog.tsx | Allows stashing alongside existing entries. |
| app/src/ui/dispatcher/dispatcher.ts | Passes stash SHAs and selected paths. |
| app/src/ui/changes/sidebar.tsx | Supplies stash entries and selection. |
| app/src/ui/changes/no-changes.tsx | Summarizes the latest stash and count. |
| app/src/ui/changes/filter-changes-list.tsx | Renders stash rows and checked-file actions. |
| app/src/ui/app.tsx | Updates stash navigation and dialogs. |
| app/src/models/stash-entry.ts | Adds creation timestamps. |
| app/src/models/popup.ts | Removes overwrite popup type. |
| app/src/models/menu-labels.ts | Removes overwrite confirmation flag. |
| app/src/main-process/menu/build-default-menu.ts | Simplifies stash menu labels. |
| app/src/lib/stores/repository-state-cache.ts | Initializes stash arrays. |
| app/src/lib/stores/git-store.ts | Retains and loads multiple stash entries. |
| app/src/lib/stores/app-store.ts | Coordinates selection, creation, and branch migration. |
| app/src/lib/menu-update.ts | Checks stash collection availability. |
| app/src/lib/git/stash.ts | Adds timestamps and path-limited stashing. |
| app/src/lib/app-state.ts | Models stash collections and SHA selection. |
Review effort: Balanced
Comment on lines
+168
to
+171
| if (paths !== undefined && paths.length > 0) { | ||
| // Use literal pathspecs so that file names containing glob characters are | ||
| // matched exactly. | ||
| args.push('--', ...paths.map(path => `:(literal)${path}`)) |
| } | ||
|
|
||
| if (await this.createStashAndDropPreviousEntry(repository, currentBranch)) { | ||
| if (await this.createStashEntry(repository, currentBranch, filePaths)) { |
Comment on lines
+1398
to
+1399
| for (const stashEntry of this.currentBranchStashEntries) { | ||
| if (stashEntry.files.kind !== StashedChangesLoadStates.NotLoaded) { |
| private onStashCheckedChanges = () => { | ||
| const paths = this.props.workingDirectory.files | ||
| .filter(file => file.isIncludedInCommit()) | ||
| .map(file => file.path) |
This branch has not been deployed
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.

Closes #12699, closes #11531
Description
GitHub Desktop currently keeps only the newest stash entry per branch:
git-storedeliberately drops every older Desktop-created stash, andcreateStashAndDropPreviousEntrydeletes the previous stash whenever the user stashes all changes or switches branches with "stash on current branch".This PR keeps the full stash stack for the current branch and surfaces it in the Changes sidebar:
git stash push -- .... Unchecked changes remain in the working directory, and selected untracked files are staged first as before.The list is still limited to Desktop-created stashes (the existing
!!GitHub_Desktop<branch>marker) for the checked-out branch; command-line stashes remain hidden, as before.Note: #12699 and #11531 are currently labeled
not-planned. This PR is a working implementation in case the team revisits that decision; the underlying issues describe the same user-facing problems.Testing performed:
npx tsc -p tsconfig.json --noEmitScreenshots
Screenshots are not included in this environment; the UI change is a list of existing stash rows in the Changes sidebar, reusing the existing stash diff viewer.
Release notes
Notes: Add support for keeping multiple stashes per branch and stashing only checked files.