git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Undo a git stash clear
@ 2008-12-16 12:07 Alexander Gladysh
  2008-12-16 12:10 ` Johannes Schindelin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexander Gladysh @ 2008-12-16 12:07 UTC (permalink / raw)
  To: git, git-users

Hi, list!

I've stashed some valuable changes and then I accidentally did git
stash clear. (Yes, today is not my day).

Is it possible to restore stashed changes?

Alexander.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Undo a git stash clear
  2008-12-16 12:07 Undo a git stash clear Alexander Gladysh
@ 2008-12-16 12:10 ` Johannes Schindelin
  2008-12-16 12:12 ` Jeff King
  2008-12-16 12:12 ` Jonathan del Strother
  2 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2008-12-16 12:10 UTC (permalink / raw)
  To: Alexander Gladysh; +Cc: git, git-users

Hi,

On Tue, 16 Dec 2008, Alexander Gladysh wrote:

> I've stashed some valuable changes and then I accidentally did git stash 
> clear. (Yes, today is not my day).
> 
> Is it possible to restore stashed changes?

You might find them with "git fsck --lost-found".

Hth,
Dscho

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Undo a git stash clear
  2008-12-16 12:07 Undo a git stash clear Alexander Gladysh
  2008-12-16 12:10 ` Johannes Schindelin
@ 2008-12-16 12:12 ` Jeff King
  2008-12-16 12:12 ` Jonathan del Strother
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2008-12-16 12:12 UTC (permalink / raw)
  To: Alexander Gladysh; +Cc: git, git-users

On Tue, Dec 16, 2008 at 03:07:28PM +0300, Alexander Gladysh wrote:

> I've stashed some valuable changes and then I accidentally did git
> stash clear. (Yes, today is not my day).
> 
> Is it possible to restore stashed changes?

Try git-fsck; it should report some dangling commits (i.e., commits that
are in the object db but aren't reachable by any refs). Then you can
either pull the changes out directly (try git cherry-pick -m1 $sha1) or you
can even restore it as a stash (git update-ref -m oops refs/stash
$sha1).

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Undo a git stash clear
  2008-12-16 12:07 Undo a git stash clear Alexander Gladysh
  2008-12-16 12:10 ` Johannes Schindelin
  2008-12-16 12:12 ` Jeff King
@ 2008-12-16 12:12 ` Jonathan del Strother
  2008-12-16 12:20   ` Matthieu Moy
  2 siblings, 1 reply; 5+ messages in thread
From: Jonathan del Strother @ 2008-12-16 12:12 UTC (permalink / raw)
  To: Alexander Gladysh; +Cc: git, git-users

On Tue, Dec 16, 2008 at 12:07 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
> Hi, list!
>
> I've stashed some valuable changes and then I accidentally did git
> stash clear. (Yes, today is not my day).
>
> Is it possible to restore stashed changes?

I ran into this exact problem on Friday.  Some helpful person on IRC
suggested using

git fsck | grep commit | cut -d' ' -f3 | while read hash; do git
rev-parse --verify --quiet $hash^2 && echo $hash; done | xargs git
show

Which will show a huge list of lost changes.  Once you find the change
you're interested in, you can cherry-pick its sha1.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Undo a git stash clear
  2008-12-16 12:12 ` Jonathan del Strother
@ 2008-12-16 12:20   ` Matthieu Moy
  0 siblings, 0 replies; 5+ messages in thread
From: Matthieu Moy @ 2008-12-16 12:20 UTC (permalink / raw)
  To: Jonathan del Strother; +Cc: Alexander Gladysh, git, git-users

"Jonathan del Strother" <maillist@steelskies.com> writes:

> On Tue, Dec 16, 2008 at 12:07 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
>> Hi, list!
>>
>> I've stashed some valuable changes and then I accidentally did git
>> stash clear. (Yes, today is not my day).
>>
>> Is it possible to restore stashed changes?
>
> I ran into this exact problem on Friday.  Some helpful person on IRC
> suggested using

(and the obvious advice before anything else : don't "git gc", don't
"git prune", and if possible back-up the repository before anything
else)

-- 
Matthieu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-16 12:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-16 12:07 Undo a git stash clear Alexander Gladysh
2008-12-16 12:10 ` Johannes Schindelin
2008-12-16 12:12 ` Jeff King
2008-12-16 12:12 ` Jonathan del Strother
2008-12-16 12:20   ` Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).