git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to restore the original head after `git-reset --hard master^`
@ 2005-10-11 15:12 Ben Lau
  2005-10-11 15:59 ` Linus Torvalds
  2005-10-11 21:37 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Ben Lau @ 2005-10-11 15:12 UTC (permalink / raw)
  To: git

Hi all,

   After involves the command `git-reset --hard master^` in a 
repository, the working
tree , current head and index are restored to the parent of master. That 
includes
the content of '.git/refs/head/master'. Although the original commit 
object is still existed
, I couldn't find it back.

  Is there anyway to recover the original master branch ? or I have to 
restore the branch
manually by finding out all the child of current head? If that is the 
solution , what command
could provide this information?

Thanks

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

* Re: How to restore the original head after `git-reset --hard master^`
  2005-10-11 15:12 How to restore the original head after `git-reset --hard master^` Ben Lau
@ 2005-10-11 15:59 ` Linus Torvalds
  2005-10-11 16:58   ` Daniel Barkalow
  2005-10-11 21:37 ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2005-10-11 15:59 UTC (permalink / raw)
  To: Ben Lau; +Cc: git



On Tue, 11 Oct 2005, Ben Lau wrote:
> 
>   After involves the command `git-reset --hard master^` in a repository, 
> the working tree , current head and index are restored to the parent of 
> master. That includes the content of '.git/refs/head/master'. Although 
> the original commit object is still existed , I couldn't find it back.
> 
>  Is there anyway to recover the original master branch ?

Just run "git-fsck-objects" and look at any dangling commits. The commit 
and related objects are still there (unless you've run "git prune"), so 
once you find the name of it, you're all done.

First check that you  have the right one by doing

	git log <name-you-found>

and if that looks right, you can just do

	git reset --hard <name-you-found>

and you should be back in business.

		Linus

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

* Re: How to restore the original head after `git-reset --hard master^`
  2005-10-11 15:59 ` Linus Torvalds
@ 2005-10-11 16:58   ` Daniel Barkalow
  2005-10-11 17:04     ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Barkalow @ 2005-10-11 16:58 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Ben Lau, git

On Tue, 11 Oct 2005, Linus Torvalds wrote:

> On Tue, 11 Oct 2005, Ben Lau wrote:
> > 
> >   After involves the command `git-reset --hard master^` in a repository, 
> > the working tree , current head and index are restored to the parent of 
> > master. That includes the content of '.git/refs/head/master'. Although 
> > the original commit object is still existed , I couldn't find it back.
> > 
> >  Is there anyway to recover the original master branch ?
> 
> Just run "git-fsck-objects" and look at any dangling commits. The commit 
> and related objects are still there (unless you've run "git prune"), so 
> once you find the name of it, you're all done.

That reminds me: if you lose all of your refs, it's hard to get them back, 
because git-fsck-objects aborts if you don't specify any heads or have any 
refs. Is there some reason for this check?

	-Daniel
*This .sig left intentionally blank*

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

* Re: How to restore the original head after `git-reset --hard master^`
  2005-10-11 16:58   ` Daniel Barkalow
@ 2005-10-11 17:04     ` Linus Torvalds
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Torvalds @ 2005-10-11 17:04 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: Ben Lau, git



On Tue, 11 Oct 2005, Daniel Barkalow wrote:
> 
> That reminds me: if you lose all of your refs, it's hard to get them back, 
> because git-fsck-objects aborts if you don't specify any heads or have any 
> refs. Is there some reason for this check?

"git prune" is the reason for that check.  Pruning your whole object store 
is likely not what you want ;)

You might make it abort only when "--unreachable" has been specified..

		Linus

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

* Re: How to restore the original head after `git-reset --hard master^`
  2005-10-11 15:12 How to restore the original head after `git-reset --hard master^` Ben Lau
  2005-10-11 15:59 ` Linus Torvalds
@ 2005-10-11 21:37 ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2005-10-11 21:37 UTC (permalink / raw)
  To: Ben Lau; +Cc: git

Ben Lau <benlau@ust.hk> writes:

>   After involves the command `git-reset --hard master^` in a 
> repository, the working
> tree , current head and index are restored to the parent of master. That 
> includes
> the content of '.git/refs/head/master'. Although the original commit 
> object is still existed
> , I couldn't find it back.

I think you can find it in .git/ORIG_HEAD.

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

end of thread, other threads:[~2005-10-11 21:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11 15:12 How to restore the original head after `git-reset --hard master^` Ben Lau
2005-10-11 15:59 ` Linus Torvalds
2005-10-11 16:58   ` Daniel Barkalow
2005-10-11 17:04     ` Linus Torvalds
2005-10-11 21:37 ` Junio C Hamano

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).