Re: [git-users] git erase everything

2012-07-06 Thread PJ Weisberg
On Fri, Jul 6, 2012 at 3:55 AM, lem torov  wrote:
> i was using netbeans ide and as CVS i was using git included into IDE.
>
> once i lanch standalone git-msys in my project directory
> git branch
> showed me
> * no branch
>   master
>   you are not in any branch
>
> i did
> git checkout master
> and i lost like 5 weeks of my work. if there is any way to restore it?

If I was a jerk, I would give you the accurate-but-unhelpful advice
that you should run the command Git told you to run in the warning
message it printed when you did 'git checkout master'.

If I was trying to be helpful I might try to teach you what a detached
HEAD is and what the reflog does, but that misses the fact that you're
panicking about losing five weeks worth of work and not interested in
learning anything until you've found it again.

So I'll give you a step-by-step:

$ git checkout master
Because I'm assuming you want these commits you're trying to
recover to be on the 'master' branch.
$ git reflog
Look in the output for the commit message of the last change
to the branch you're trying to restore
$ git reset --merge abc123
Here, 'abc123' is the sha1 of the commit you noted in the
previous step.  You can replace '--merge' with '--hard' if there are
no changes in your current working directory that you want to
preserve, but I'm recommending the safer option for people who find
this post on Google in the future. :-)

That will leave the 'master' branch pointing at the commit 'abc123'.
(In Git, branches and tags are simply pointers to specific commits.)

Now in the future, if you 'checkout' anything other than a branch,
remember to 'checkout' a branch again before you commit anything you
want to keep!

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread Konstantin Khomoutov
On Fri, 6 Jul 2012 04:42:07 -0700 (PDT)
lem torov  wrote:

[...]
> > And to get hold of this "detached HEAD" concept, read this: 
> > http://sitaramc.github.com/concepts/detached-head.html 
> 
> if there are desctiption how to into not in branch. If I do have a
> single branch. How do I get out of it. I mean when i run 
> *git branch *
> i was getting  output that i am in branch "* no branch", but if i try 
> *git checkout no branch*
> result is *such branch doesnot exist.*
The `git branch` lists the branches present in your repository and marks
the currently checked out branch using the asterisk sign ("*").
It also ought to have a way to somehow indicate that what's currently
checked out does not belong to any branch.  So it does this by printing
"no branch".  If you think that's incorrect/inconvenient/confusing or
whatever else feel free to summarise your ideas on the main Git list
(git at vger.kernel.org).

> how i could possible to get in there.
The ways to get into that state are well explained in the tutorial
I linked to.  But note that your IDE is another factor to consider.

> in fact now i did as it was proposed and i did checked out commit
> preceding time when i did destroyed repo into branch "recover". and
> them i did *git checkout recover
> *nothing happend. there are no files which suppose to be in where.
> and I did today 2 commits.*
You hasn't been told to "check out a commit from preceeding time",
it was proposed that you inspect the output of `git reflog` carefully
(*after* reading a suitable guide on what the reflog shows you and how
to interpret that info) and then try to figure out what reflog entry
points to the commit you HEAD pointed to before you moved it by
checking out an existing branch.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread Konstantin Khomoutov
On Fri, 6 Jul 2012 05:01:55 -0700 (PDT)
lem torov  wrote:

> > > I follow you tutorial 
> > Actually, I gather that this more modern guide [1] written by the
> > same author is indeed better (linked from the original tutorial). 
> >
> > 1. 
> > http://sitaramc.github.com/gcs/index.html#gcs_index_detached_HEAD_and_all_that_
> >  
> >
> 
> question is not "what is head"  or "what is detached head". question
> is how did i get into "no branch" branch. why there is no any notice
> when i did commit into no branch.
> and if commits are registered why those commits doesnot contain files
> which i did commit into it.

In your original mail you stated:
"i was using netbeans ide ..."
hence the only sensible answer to the first two questions is "ask
netbeans folks".

With plain Git, there are several ways to get into the detached HEAD
state; they are all summarised in the article I referred to.

Making a wild guess, I suspect that your IDE allowed you to check out a
remote branch or a tag.

The last question is more tricky.  One possibility is that your guess
about what commit the HEAD was pointing to before you checked out a
branch was wrong.  Try looking at your reflog more carefully, make
temporary tags or branches out of any commits you think might be the
correct lost HEAD and inspect them one by one until you find the right
one.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread lem torov


пятница, 6 июля 2012 г., 15:45:25 UTC+4 пользователь Konstantin Khomoutov 
написал:
>
>
> > I follow you tutorial 
> Actually, I gather that this more modern guide [1] written by the same 
> author is indeed better (linked from the original tutorial). 
>
> 1. 
> http://sitaramc.github.com/gcs/index.html#gcs_index_detached_HEAD_and_all_that_
>  
>

question is not "what is head"  or "what is detached head". question is how 
did i get into "no branch" branch. why there is no any notice when i did 
commit into no branch.
and if commits are registered why those commits doesnot contain files which 
i did commit into it.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/z8Lqra5zFJAJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread Konstantin Khomoutov
On Fri, 6 Jul 2012 04:29:45 -0700 (PDT)
lem torov  wrote:

> I follow you tutorial
Actually, I gather that this more modern guide [1] written by the same
author is indeed better (linked from the original tutorial).

1. 
http://sitaramc.github.com/gcs/index.html#gcs_index_detached_HEAD_and_all_that_

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread lem torov


пятница, 6 июля 2012 г., 15:18:39 UTC+4 пользователь Konstantin Khomoutov 
написал:
>
>
> > i was using netbeans ide and as CVS i was using git included into IDE. 
> > 
> > once i lanch standalone git-msys in my project directory 
> > git branch 
> > showed me 
> > ** no branch 
> >   master 
> >   you are not in any branch 
> > * 
> > i did 
> > *git checkout master* 
> > and i lost like 5 weeks of my work. if there is any way to restore it? 
>
> Follow the advice given by Aneesh. 
>
> And to get hold of this "detached HEAD" concept, read this: 
> http://sitaramc.github.com/concepts/detached-head.html 
>

if there are desctiption how to into not in branch. If I do have a single 
branch. How do I get out of it. I mean when i run 
*git branch *
i was getting  output that i am in branch "* no branch", but if i try 
*git checkout no branch*
result is *such branch doesnot exist.*
how i could possible to get in there.

in fact now i did as it was proposed and i did checked out commit preceding 
time when i did destroyed repo into branch "recover". and them i did 
*git checkout recover
*nothing happend. there are no files which suppose to be in where. and I 
did today 2 commits.*
*

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/Txsi5TnNqPQJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread lem torov
I follow you tutorial

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/8oh273MuSMoJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread Konstantin Khomoutov
On Fri, 6 Jul 2012 03:55:03 -0700 (PDT)
lem torov  wrote:

> i was using netbeans ide and as CVS i was using git included into IDE.
> 
> once i lanch standalone git-msys in my project directory
> git branch
> showed me
> ** no branch
>   master
>   you are not in any branch
> *
> i did 
> *git checkout master*
> and i lost like 5 weeks of my work. if there is any way to restore it?

Follow the advice given by Aneesh.

And to get hold of this "detached HEAD" concept, read this:
http://sitaramc.github.com/concepts/detached-head.html

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] git erase everything

2012-07-06 Thread Aneesh Bhasin
Hi Lem,

On Fri, Jul 6, 2012 at 4:25 PM, lem torov  wrote:
>
> i was using netbeans ide and as CVS i was using git included into IDE.
>
> once i lanch standalone git-msys in my project directory
> git branch
> showed me
> * no branch
>   master
>   you are not in any branch
>
> i did
> git checkout master
> and i lost like 5 weeks of my work. if there is any way to restore it?
>

'git reflog' is your friend. Try this command - it should show your
where the HEAD pointed to in last few operations. Using it you should
be able to figure out the commit id of the tip of the dangling branch
you were earlier on.
Once you have the commit id, just do:

git checkout -b my_old_branch 

This will create a new 'my_old_branch' pointing to that commit...

regards,
Aneesh

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.