-
-
Save ArturJS/7267b29f9d0371db2a71750997b79b62 to your computer and use it in GitHub Desktop.
Revisions
-
joseluisq revised this gist
Oct 11, 2019 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,16 @@ # How to recover a dropped stash in Git? ## 1. Find the stash commits ```sh git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) ``` _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._ __bash/sh shell users:__ Version above is for Fish shell, so if you are bash/sh user just add a `$` sign before to the left parenthesis. ## 2. Once you know the hash of the commit you want, you can apply it as a stash ```sh git stash apply YOUR_WIP_COMMIT_HASH -
joseluisq revised this gist
Feb 2, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ # How to recover a dropped stash in Git? __1. Find the stash commits:__ ```sh git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) ``` _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._ __2. Once you know the hash of the commit you want, you can apply it as a stash:__ ```sh git stash apply YOUR_WIP_COMMIT_HASH -
joseluisq created this gist
Feb 2, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # How to recover a dropped stash in Git? 1. Find the stash commits: ```sh git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) ``` _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._ 2. Once you know the hash of the commit you want, you can apply it as a stash: ```sh git stash apply YOUR_WIP_COMMIT_HASH ``` _Note: The commit message will only be in this form (starting with "WIP on") if you did not supply a message when you did git stash._ __Source:__ View the complete answer at https://stackoverflow.com/a/91795/2510591