git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git: avoiding merges, rebasing

From
BHBruno Haible <bruno@clisp.org>
Date
Oct 3, 2007, 23:01 UTC
Message-ID
<200710040101.52137.bruno@clisp.org>
In-Reply-To
<6C9F1445-8826-4E6F-A10C-290A57A4C826@lrde.epita.fr>
Benoit SIGOURE wrote:
Show 12 quoted lines
> >>> 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 <sha1>) 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 <commit>`.
++
+----------------------------------------------------------------
+... 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],
Previous: Miles BaderNext: Benoit SIGOURE
Message 8 of 15 in “Re: git: avoiding merges, rebasing”
  1. Eric BlakeOct 2, 2007
  2. making "git stash" safer to useBruno Haible, Oct 3, 2007
  3. Junio C HamanoOct 3, 2007
  4. Joachim B HagaOct 4, 2007
  5. David KastrupOct 4, 2007
  6. stash clear, was Re: git: avoiding merges, rebasingJohannes Schindelin, Oct 19, 2007
  7. Miles BaderOct 23, 2007
  8. Bruno HaibleOct 3, 2007
  9. Benoit SIGOUREOct 8, 2007
  10. Benoit SIGOUREOct 8, 2007
  11. Johannes SchindelinOct 9, 2007
  12. Benoit SIGOUREOct 9, 2007
  13. Bruno HaibleOct 9, 2007
  14. GNU-style ChangeLog merge driver for Git (was: Re: git: avoiding merges, rebasing)Benoit SIGOURE, Oct 9, 2007
  15. Bruno HaibleOct 9, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.