You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GitHub Desktop may overwrite existing stash when "Always stash and leave my changes" is selected #10956
When checking out a branch using the pull request list or by following a "Checkout in Desktop" link on GitHub.com while having the "Always stash and leave my changes on the current branch" option selected in preferences (under Advanced) GitHub Desktop fails to prompt the user for confirmation before overwriting their existing stash.
Version & OS
I believe this has been true since #8813 which shipped in 2.3.0. OS-independent
Steps to reproduce the behavior
Ensure your current branch has a stash associated with it.
Ensure you have uncommitted changes in your working directory
Ensure you've selected the "Always stash and leave my changes on the current branch" option in preferences
Attempt to check out a pull request (note: not a branch, there's different logic involved here)
Expected behavior
GitHub Desktop should show a confirmation prompt like the one below
Actual behavior
The PR branch is checked out and the stash on the previous branch is overwritten with a newly created stash containing your uncommitted changes.
Additional context
I've got a fix ready for this, I just wanted to ensure we have a record of this being a bug that we can refer back to. The dropped stash can be restored by looking through the GitHub Desktop logs and searching for a message with the following format:
info: [ui] Dropped stash '0e95c933c4c6ba4403564407f2c8a7fbe829fb3d' associated with main
Taking that stash SHA one could restore the changes by running git stash apply 0e95c933c4c6ba4403564407f2c8a7fbe829fb3d
This is a bug? I don't know why anyone would want to overwrite their stash period. When I stash on CLI before switching branch, I don't need to overwrite a stash. The stash records the branch I'm on anyway. I just stash, switch branches, then unstash from the stash I see is marked as for that branch. I don't know why GitHub Desktop needs to overwrite stashes at all.
I second this and add that the "Your current stash will be overwritten by creating a new stash" message on the "stash my changes and switch branches" dialog is way too subtle:
A destructive procedure such as overwriting a current stash should require an explicit confirmation of intent, ideally in a separate dialog, as you mocked up.
I've hit the "switch branch" button too quickly a couple of times (muscle memory, combined with the destructive action being highlighted blue) before realizing what i've done 😫 thank god for git fsck...
Activity
givihuda commentedon Dec 21, 2021
This is a bug? I don't know why anyone would want to overwrite their stash period. When I stash on CLI before switching branch, I don't need to overwrite a stash. The stash records the branch I'm on anyway. I just stash, switch branches, then unstash from the stash I see is marked as for that branch. I don't know why GitHub Desktop needs to overwrite stashes at all.
gnowland commentedon Jun 17, 2022
I second this and add that the "Your current stash will be overwritten by creating a new stash" message on the "stash my changes and switch branches" dialog is way too subtle:
A destructive procedure such as overwriting a current stash should require an explicit confirmation of intent, ideally in a separate dialog, as you mocked up.
I've hit the "switch branch" button too quickly a couple of times (muscle memory, combined with the destructive action being highlighted blue) before realizing what i've done 😫 thank god for
git fsck...