Quantcast
Channel: How do I recover a dropped stash in Git? - Stack Overflow
Viewing all articles
Browse latest Browse all 52

Answer by Kartoos for How do I recover a dropped stash in Git?

$
0
0

Github Desktop

If you stashed your changes using Github Desktop, and accidentally removed your stashed changes, then you can run the following to search for dangling stash commit (based on this answer):

Note: If using Windows, run the commands using Git Bash (which is installed alongside git installation)

git log --graph --oneline --decorate --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) | grep 'GitHub_Desktop'

You will get a list of commits like:

| *   b7f1b023 On main: !!GitHub_Desktop<main>| * 7e949012 On main: !!GitHub_Desktop<main>| * 7de9b9ca On main: !!GitHub_Desktop<main>

Get the commit of the first one in the list. In the above example, it will be b7f1b023 and run the following:

git stash apply b7f1b023

This will recover your changes. If it doesn't, you can try other commits in the output.


Viewing all articles
Browse latest Browse all 52

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>