From: Bruno Haible Date: Wed, 03 Oct 2007 23:01:52 GMT Subject: Re: git: avoiding merges, rebasing Message-ID: <200710040101.52137.bruno@clisp.org> In-Reply-To: <6C9F1445-8826-4E6F-A10C-290A57A4C826@lrde.epita.fr> Benoit SIGOURE wrote: > >>> Is there some shorthand for this process, such as a "git-recover" > >>> command? > >> > >> you can run git fsck and look for > >> a dangling commit (which can be inspected with git show ) where > >> you are most likely to find your stash (unless you run git-gc or this > >> sort of thing). > > > > Cool! This information would be worth mentioning in the git-stash > > manual page or in an FAQ. It can be a real life-saver. > > True. Propose a patch :-) Here's a proposed patch. --- git-1.5.3.4/Documentation/git-stash.txt.bak 2007-10-03 21:44:53.000000000 +0200 +++ git-1.5.3.4/Documentation/git-stash.txt 2007-10-04 01:00:48.000000000 +0200 @@ -154,6 +154,28 @@ ... continue hacking ... ---------------------------------------------------------------- +Recovering a lost stash:: + +`git stash clear` clears all stashes without asking for confirmation. +If you did not intend this, you can recover the lost changes by running +`git fsck`, looking for dangling commits, and using `git show `. ++ +---------------------------------------------------------------- +... hack hack hack ... +$ git stash +... hack no coffee hack ... +$ git stash clear +... panic panic ... +$ git fsck +dangling commit f62c4fa05422fd4fb8610bdb02a7160121657893 +dangling commit 773024d2ffc33ac80baddcf2b673535b627af0da +dangling commit 9e509390a2b26b562f3b008eacc65b6765d48339 +$ git show 773024d2ffc33ac80baddcf2b673535b627af0da +$ git diff 773024d2ffc33ac80baddcf2b673535b627af0da > recovered.diff +$ patch -p0 -R < recovered.diff +... continue hacking ... +---------------------------------------------------------------- + SEE ALSO -------- gitlink:git-checkout[1],