Skip to content

Commit

Permalink
Document 'stash clear' recovery via unreachable commits
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Rast authored and Junio C Hamano committed Aug 10, 2009
1 parent c14417c commit f5f1e16
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Documentation/git-stash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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] [<stash>]::

Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit f5f1e16

Please sign in to comment.