From: Thomas Rast Date: Sun, 9 Aug 2009 00:47:36 +0000 (+0200) Subject: Document 'stash clear' recovery via unreachable commits X-Git-Tag: v1.6.5-rc0~91 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f5f1e164bd4234683e5a1fc4a49a77b1b01855f8;p=git.git Document 'stash clear' recovery via unreachable commits Add an example to the stash documentation that shows how to quickly find candidate commits among the 'git fsck --unreachable' output. Unless you have merges of branch names containing WIP, or edit your merge messages to say WIP, there will be no false positives. Snippet written by Björn "doener" Steinbrink and me after zepolen_ asked on IRC. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 1c64a02fe..2f5ca7b1a 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -114,7 +114,8 @@ no conflicts. clear:: Remove all the stashed states. Note that those states will then - be subject to pruning, and may be difficult or impossible to recover. + be subject to pruning, and may be impossible to recover (see + 'Examples' below for a possible strategy). drop [-q|--quiet] []:: @@ -217,6 +218,20 @@ $ edit/build/test remaining parts $ git commit foo -m 'Remaining parts' ---------------------------------------------------------------- +Recovering stashes that were cleared/dropped erroneously:: + +If you mistakenly drop or clear stashes, they cannot be recovered +through the normal safety mechanisms. However, you can try the +following incantation to get a list of stashes that are still in your +repository, but not reachable any more: ++ +---------------------------------------------------------------- +git fsck --unreachable | +grep commit | cut -d\ -f3 | +xargs git log --merges --no-walk --grep=WIP +---------------------------------------------------------------- + + SEE ALSO -------- linkgit:git-checkout[1],