Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have only just popped it and the terminal is still open, you will <a href="https://stackoverflow.com/questions/89332/recover-dropped-stash-in-git/7844566#7844566">still have the hash value printed by <code>git stash pop</code> on screen</a> (thanks, Dolda).</p> <p>Otherwise, you can find it using this for Linux and Unix:</p> <pre><code>git fsck --no-reflog | awk '/dangling commit/ {print $3}' </code></pre> <p>and for Windows:</p> <pre><code>git fsck --no-reflog | select-string 'dangling commit' | foreach { $bits = $_ -split ' '; echo $bits[2];} </code></pre> <p>This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.</p> <p>The easiest way to find the stash commit you want is probably to pass that list to <code>gitk</code>:</p> <pre><code>gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) </code></pre> <p>This will launch a repository browser showing you <em>every single commit in the repository ever</em>, regardless of whether it is reachable or not.</p> <p>You can replace <code>gitk</code> there with something like <code>git log --graph --oneline --decorate</code> if you prefer a nice graph on the console over a separate GUI app.</p> <p>To spot stash commits, look for commit messages of this form:</p> <p>&#160; &#160; &#160; &#160; WIP on <i>somebranch</i>: <i>commithash Some old commit message</i></p> <p><em>Note</em>: The commit message will only be in this form (starting with "WIP on") if you did not supply a message when you did <code>git stash</code>.</p> <p>Once you know the hash of the commit you want, you can apply it as a stash:</p> <pre><code>git stash apply <i>$stash_hash</i></code></pre> <p>Or you can use the context menu in <code>gitk</code> to create branches for any unreachable commits you are interested in. After that, you can do whatever you want with them with all the normal tools. When you’re done, just blow those branches away again.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload