Background
Picture this: You have a stash in GitHub Desktop, and you overwrite it by mistake. You now enter the
ohnosecond.
You might think that you've lost the changes forever, but fear not! There's a way to recover an overwritten stash in GitHub Desktop.
Steps to recover an overwritten stash in GitHub Desktop
First, you need to find the logs from GitHub Desktop. Here are the paths where you can find the logs:
# Windows
'C:\Users\USERNAME\AppData\Roaming\GitHub Desktop\logs'
# macOS
'/Users/USERNAME/Library/Application Support/GitHub Desktop/logs'
# You can also use the "Help" tab in the menu bar and click on the "Show logs in Finder" option
Next, find the latest log file, it will look something like 2024-04-11.desktop.production.log
and open it in a text editor.
Now, use the search function Ctrl+F to search for "Dropped stash". You should find a line that looks like this:
2024-04-11T12:20:52.053Z - info: [ui] Dropped stash 'd3f88bb8f11798d3d6505b579ef140fc61da05cc' associated with master
The hash d3f88bb8f11798d3d6505b579ef140fc61da05cc
is the identifier for the dropped stash.
Copy this hash as this is what we are looking for. Of course, your hash will be different.
Now, open a terminal and navigate to your repository. Run the following command to create a branch called recovery
based on the dropped stash:
git checkout -b recovery d3f88bb8f11798d3d6505b579ef140fc61da05cc # Replace the hash with your own
And that's it! You've recovered the overwritten stash in GitHub Desktop.
If you now open Desktop back up you should see the changes in the recovery branch.
From here, you can cherry pick the changes you need to your original branch.
Conclusion
I hope this guide helps you recover an overwritten stash in GitHub Desktop! If it saved you some time, consider sharing it with others who might find it useful.
- You can support me by following me on Twitter CodeWithCaen. If I really helped, you can also Buy me a coffee!
- You can also support the original authors by visiting the post on Stackoverflow linked below and upvoting the answer.
Attributions
The sources and instructions for this post are based on content from Stackoverflow
Recover dropped Stashed Changes in GitHub Desktop (Windows 10),
by various authors, with content licenced under "CC BY-SA 4.0" which this post is also licenced under.
Top comments (0)