All of lore.kernel.org
 help / color / mirror / Atom feed
* Lost a week?
@ 2010-04-15 13:57 Daniel Grace
  2010-04-15 14:11 ` Michael J Gruber
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Daniel Grace @ 2010-04-15 13:57 UTC (permalink / raw)
  To: git

Appologies for not having more information. I usually use git as if
it's just SVN with non-network checkins.

A few days ago, I pushed my git repository to github:

127  git remote add github
git@github.com:negativeview/Wherespresso.git [Note, this is a private
repo]
128  git push github master

I then went about doing real-world business. I noticed at some point
that when I did a `git status` it said that no branches were checked
out. I don't remember doing anything between pushing to github and
this state. If I did a git branch it shows something like * (no
branch) then below that, master. I shrugged it off and did what I
expected to fix that odd issue:

515  git branch
516  git checkout master

Now, the next day, I noticed that I have no git history between the
6th and something I did soon after the git checkout master:

$ git log | grep Date | head -n 5
Date:   Wed Apr 14 14:43:58 2010 -0500
Date:   Tue Apr 6 00:42:20 2010 -0500
Date:   Mon Apr 5 23:57:54 2010 -0500
Date:   Mon Apr 5 07:01:26 2010 -0500
Date:   Mon Apr 5 06:17:18 2010 -0500

github shows the same. I KNOW that there were commits (representing a
good bit of work) in that time. I'm sure that it's *somewhere* but I'm
at a complete loss as to where it is. gitk shows no side branches (nor
does git branch). I don't use branches really, as much as I know that
I should.

Daniel
http://www.doomstick.com

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

* Re: Lost a week?
  2010-04-15 13:57 Lost a week? Daniel Grace
@ 2010-04-15 14:11 ` Michael J Gruber
  2010-04-15 14:16 ` Thomas Rast
  2010-04-15 14:16 ` Matthieu Moy
  2 siblings, 0 replies; 5+ messages in thread
From: Michael J Gruber @ 2010-04-15 14:11 UTC (permalink / raw)
  To: Daniel Grace; +Cc: git

Daniel Grace venit, vidit, dixit 15.04.2010 15:57:
> Appologies for not having more information. I usually use git as if
> it's just SVN with non-network checkins.
> 
> A few days ago, I pushed my git repository to github:
> 
> 127  git remote add github
> git@github.com:negativeview/Wherespresso.git [Note, this is a private
> repo]
> 128  git push github master
> 
> I then went about doing real-world business. I noticed at some point
> that when I did a `git status` it said that no branches were checked
> out. I don't remember doing anything between pushing to github and
> this state. If I did a git branch it shows something like * (no
> branch) then below that, master. I shrugged it off and did what I
> expected to fix that odd issue:
> 
> 515  git branch
> 516  git checkout master
> 
> Now, the next day, I noticed that I have no git history between the
> 6th and something I did soon after the git checkout master:
> 
> $ git log | grep Date | head -n 5
> Date:   Wed Apr 14 14:43:58 2010 -0500
> Date:   Tue Apr 6 00:42:20 2010 -0500
> Date:   Mon Apr 5 23:57:54 2010 -0500
> Date:   Mon Apr 5 07:01:26 2010 -0500
> Date:   Mon Apr 5 06:17:18 2010 -0500
> 
> github shows the same. I KNOW that there were commits (representing a
> good bit of work) in that time. I'm sure that it's *somewhere* but I'm
> at a complete loss as to where it is. gitk shows no side branches (nor
> does git branch). I don't use branches really, as much as I know that
> I should.
> 
> Daniel
> http://www.doomstick.com

Backup now.

Most probably, you've made those commits on a detached HEAD. May you
have checked out a remote branch, or a specific commit, before you went
about your business on or after 6th?

git reflog (or git log -g) will be able to show you the history of your
HEAD before you lost it ;)

Then you can tag those commits or 'checkout -b safehaven
nameofthetopcommit' to get a branch with those commits. Now they are
safe from being pruned during garbage collection.

Michael

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

* Re: Lost a week?
  2010-04-15 13:57 Lost a week? Daniel Grace
  2010-04-15 14:11 ` Michael J Gruber
@ 2010-04-15 14:16 ` Thomas Rast
  2010-04-15 14:16 ` Matthieu Moy
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Rast @ 2010-04-15 14:16 UTC (permalink / raw)
  To: Daniel Grace; +Cc: git

Daniel Grace wrote:
> I then went about doing real-world business. I noticed at some point
> that when I did a `git status` it said that no branches were checked
> out.

Read this: http://sitaramc.github.com/concepts/detached-head.html

(I don't want to sound dismissive, there's just not much not covered
in that article :-)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

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

* Re: Lost a week?
  2010-04-15 13:57 Lost a week? Daniel Grace
  2010-04-15 14:11 ` Michael J Gruber
  2010-04-15 14:16 ` Thomas Rast
@ 2010-04-15 14:16 ` Matthieu Moy
  2010-04-15 14:29   ` Daniel Grace
  2 siblings, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2010-04-15 14:16 UTC (permalink / raw)
  To: Daniel Grace; +Cc: git

Daniel Grace <negativeview@gmail.com> writes:

> github shows the same. I KNOW that there were commits (representing a
> good bit of work) in that time. I'm sure that it's *somewhere* but I'm
> at a complete loss as to where it is. gitk shows no side branches (nor
> does git branch). I don't use branches really, as much as I know that
> I should.

I guess you've been on a detached HEAD for some time. Recent version
of Git warn you this way when you enter in this state:

,----
| Note: checking out 'HEAD^'.
| 
| You are in 'detached HEAD' state. You can look around, make experimental
| changes and commit them, and you can discard any commits you make in this
| state without impacting any branches by performing another checkout.
| 
| If you want to create a new branch to retain commits you create, you may
| do so (now or later) by using -b with the checkout command again. Example:
| 
|   git checkout -b new_branch_name
| 
| HEAD is now at a8e7ba9... foo
`----

Now, your changes are probably not lost forever: they're not reachable
from a branch, but still there (but don't play with "git gc" until
you're sure you've recovered all of it...). "git reflog" should give
you the sha1 of the commit you're looking for (if you didn't really
mess up everything, you really look for just one commit, which is the
tip of the sequence of commits you did while on a detached HEAD, that
is, the one just before you did "git checkout master".

Then, do

git branch tmp <the-sha1-you-found>
(possibly run "gitk --all" to understand, here)
git merge tmp

to create a branch named tmp containing your commits, and merge it
into your current branch. Naming the branch isn't strictly necessary,
but will help in case you do anything wrong trying to merge.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

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

* Re: Lost a week?
  2010-04-15 14:16 ` Matthieu Moy
@ 2010-04-15 14:29   ` Daniel Grace
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Grace @ 2010-04-15 14:29 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

Thanks everyone! I had heard the phrase "detached head" before, but
didn't really understand what it is. I'm glad to note that all my
commits were there. I wasn't really worried, I knew that git had
stored it dutifully away SOMEWHERE.

I have that page bookmarked now Thomas. Unfortunately I have customer
work to do now that I am not missing work, but I promise to read and
understand it fully as soon as I'm done with that.

Daniel
http://www.doomstick.com



On Thu, Apr 15, 2010 at 9:16 AM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Daniel Grace <negativeview@gmail.com> writes:
>
>> github shows the same. I KNOW that there were commits (representing a
>> good bit of work) in that time. I'm sure that it's *somewhere* but I'm
>> at a complete loss as to where it is. gitk shows no side branches (nor
>> does git branch). I don't use branches really, as much as I know that
>> I should.
>
> I guess you've been on a detached HEAD for some time. Recent version
> of Git warn you this way when you enter in this state:
>
> ,----
> | Note: checking out 'HEAD^'.
> |
> | You are in 'detached HEAD' state. You can look around, make experimental
> | changes and commit them, and you can discard any commits you make in this
> | state without impacting any branches by performing another checkout.
> |
> | If you want to create a new branch to retain commits you create, you may
> | do so (now or later) by using -b with the checkout command again. Example:
> |
> |   git checkout -b new_branch_name
> |
> | HEAD is now at a8e7ba9... foo
> `----
>
> Now, your changes are probably not lost forever: they're not reachable
> from a branch, but still there (but don't play with "git gc" until
> you're sure you've recovered all of it...). "git reflog" should give
> you the sha1 of the commit you're looking for (if you didn't really
> mess up everything, you really look for just one commit, which is the
> tip of the sequence of commits you did while on a detached HEAD, that
> is, the one just before you did "git checkout master".
>
> Then, do
>
> git branch tmp <the-sha1-you-found>
> (possibly run "gitk --all" to understand, here)
> git merge tmp
>
> to create a branch named tmp containing your commits, and merge it
> into your current branch. Naming the branch isn't strictly necessary,
> but will help in case you do anything wrong trying to merge.
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
>

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

end of thread, other threads:[~2010-04-15 14:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-15 13:57 Lost a week? Daniel Grace
2010-04-15 14:11 ` Michael J Gruber
2010-04-15 14:16 ` Thomas Rast
2010-04-15 14:16 ` Matthieu Moy
2010-04-15 14:29   ` Daniel Grace

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.