@matheusbsbs / matheus-bagliano / commits / f5f1e164bd
Fork 0

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 <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Aug 9, 2009 at 02:47 UTC f5f1e164bd4234683e5a1fc4a49a77b1b01855f8
1 file changed +16 -1
Documentation/git-stash.txt
+16 -1
@@ -114,7 +114,8 @@ no conflicts.
114
115 clear::
116 Remove all the stashed states. Note that those states will then
117 - be subject to pruning, and may be difficult or impossible to recover.
117 + be subject to pruning, and may be impossible to recover (see
118 + 'Examples' below for a possible strategy).
119
120 drop [-q|--quiet] [<stash>]::
121
@@ -217,6 +218,20 @@ $ edit/build/test remaining parts
218 $ git commit foo -m 'Remaining parts'
219 ----------------------------------------------------------------
220
221 +Recovering stashes that were cleared/dropped erroneously::
222 +
223 +If you mistakenly drop or clear stashes, they cannot be recovered
224 +through the normal safety mechanisms. However, you can try the
225 +following incantation to get a list of stashes that are still in your
226 +repository, but not reachable any more:
227 ++
228 +----------------------------------------------------------------
229 +git fsck --unreachable |
230 +grep commit | cut -d\ -f3 |
231 +xargs git log --merges --no-walk --grep=WIP
232 +----------------------------------------------------------------
233 +
234 +
235 SEE ALSO
236 --------
237 linkgit:git-checkout[1],