{"thread":{"id":"23478","subject":"Lost a week?","startedAt":"2010-04-15T13:57:50Z","lastAt":"2010-04-15T14:29:26Z","messageCount":5,"participants":["Daniel Grace","Michael J Gruber","Thomas Rast","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"139589","messageId":"t2s62a3a9cb1004150657g5baabb42o512e0e103d1e9596@mail.gmail.com","threadId":"23478","inReplyTo":null,"subject":"Lost a week?","fromName":"Daniel Grace","fromEmail":"negativeview@gmail.com","sentAt":"2010-04-15T13:57:50Z","receivedAt":"2010-04-15T13:57:50Z","isPatch":false,"sender":{"key":"negativeview@gmail.com","avatar":"https://gravatar.com/avatar/3cdfd055fcddbe166daf37ce403bfce216b100e8fc783998f43938ff77c388dc?d=mp&s=160"},"body":"Appologies for not having more information. I usually use git as if\nit's just SVN with non-network checkins.\n\nA few days ago, I pushed my git repository to github:\n\n127  git remote add github\ngit@github.com:negativeview/Wherespresso.git [Note, this is a private\nrepo]\n128  git push github master\n\nI then went about doing real-world business. I noticed at some point\nthat when I did a `git status` it said that no branches were checked\nout. I don't remember doing anything between pushing to github and\nthis state. If I did a git branch it shows something like * (no\nbranch) then below that, master. I shrugged it off and did what I\nexpected to fix that odd issue:\n\n515  git branch\n516  git checkout master\n\nNow, the next day, I noticed that I have no git history between the\n6th and something I did soon after the git checkout master:\n\n$ git log | grep Date | head -n 5\nDate:   Wed Apr 14 14:43:58 2010 -0500\nDate:   Tue Apr 6 00:42:20 2010 -0500\nDate:   Mon Apr 5 23:57:54 2010 -0500\nDate:   Mon Apr 5 07:01:26 2010 -0500\nDate:   Mon Apr 5 06:17:18 2010 -0500\n\ngithub shows the same. I KNOW that there were commits (representing a\ngood bit of work) in that time. I'm sure that it's *somewhere* but I'm\nat a complete loss as to where it is. gitk shows no side branches (nor\ndoes git branch). I don't use branches really, as much as I know that\nI should.\n\nDaniel\nhttp://www.doomstick.com\n"},{"id":"139590","messageId":"4BC71EAC.8050602@drmicha.warpmail.net","threadId":"23478","inReplyTo":"t2s62a3a9cb1004150657g5baabb42o512e0e103d1e9596@mail.gmail.com","subject":"Re: Lost a week?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-04-15T14:11:56Z","receivedAt":"2010-04-15T14:11:56Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Daniel Grace venit, vidit, dixit 15.04.2010 15:57:\n> Appologies for not having more information. I usually use git as if\n> it's just SVN with non-network checkins.\n> \n> A few days ago, I pushed my git repository to github:\n> \n> 127  git remote add github\n> git@github.com:negativeview/Wherespresso.git [Note, this is a private\n> repo]\n> 128  git push github master\n> \n> I then went about doing real-world business. I noticed at some point\n> that when I did a `git status` it said that no branches were checked\n> out. I don't remember doing anything between pushing to github and\n> this state. If I did a git branch it shows something like * (no\n> branch) then below that, master. I shrugged it off and did what I\n> expected to fix that odd issue:\n> \n> 515  git branch\n> 516  git checkout master\n> \n> Now, the next day, I noticed that I have no git history between the\n> 6th and something I did soon after the git checkout master:\n> \n> $ git log | grep Date | head -n 5\n> Date:   Wed Apr 14 14:43:58 2010 -0500\n> Date:   Tue Apr 6 00:42:20 2010 -0500\n> Date:   Mon Apr 5 23:57:54 2010 -0500\n> Date:   Mon Apr 5 07:01:26 2010 -0500\n> Date:   Mon Apr 5 06:17:18 2010 -0500\n> \n> github shows the same. I KNOW that there were commits (representing a\n> good bit of work) in that time. I'm sure that it's *somewhere* but I'm\n> at a complete loss as to where it is. gitk shows no side branches (nor\n> does git branch). I don't use branches really, as much as I know that\n> I should.\n> \n> Daniel\n> http://www.doomstick.com\n\nBackup now.\n\nMost probably, you've made those commits on a detached HEAD. May you\nhave checked out a remote branch, or a specific commit, before you went\nabout your business on or after 6th?\n\ngit reflog (or git log -g) will be able to show you the history of your\nHEAD before you lost it ;)\n\nThen you can tag those commits or 'checkout -b safehaven\nnameofthetopcommit' to get a branch with those commits. Now they are\nsafe from being pruned during garbage collection.\n\nMichael\n"},{"id":"139592","messageId":"201004151616.13750.trast@student.ethz.ch","threadId":"23478","inReplyTo":"t2s62a3a9cb1004150657g5baabb42o512e0e103d1e9596@mail.gmail.com","subject":"Re: Lost a week?","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-04-15T14:16:13Z","receivedAt":"2010-04-15T14:16:13Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Daniel Grace wrote:\n> I then went about doing real-world business. I noticed at some point\n> that when I did a `git status` it said that no branches were checked\n> out.\n\nRead this: http://sitaramc.github.com/concepts/detached-head.html\n\n(I don't want to sound dismissive, there's just not much not covered\nin that article :-)\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"139593","messageId":"vpqtyrc6bse.fsf@bauges.imag.fr","threadId":"23478","inReplyTo":"t2s62a3a9cb1004150657g5baabb42o512e0e103d1e9596@mail.gmail.com","subject":"Re: Lost a week?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-04-15T14:16:49Z","receivedAt":"2010-04-15T14:16:49Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Daniel Grace <negativeview@gmail.com> writes:\n\n> github shows the same. I KNOW that there were commits (representing a\n> good bit of work) in that time. I'm sure that it's *somewhere* but I'm\n> at a complete loss as to where it is. gitk shows no side branches (nor\n> does git branch). I don't use branches really, as much as I know that\n> I should.\n\nI guess you've been on a detached HEAD for some time. Recent version\nof Git warn you this way when you enter in this state:\n\n,----\n| Note: checking out 'HEAD^'.\n| \n| You are in 'detached HEAD' state. You can look around, make experimental\n| changes and commit them, and you can discard any commits you make in this\n| state without impacting any branches by performing another checkout.\n| \n| If you want to create a new branch to retain commits you create, you may\n| do so (now or later) by using -b with the checkout command again. Example:\n| \n|   git checkout -b new_branch_name\n| \n| HEAD is now at a8e7ba9... foo\n`----\n\nNow, your changes are probably not lost forever: they're not reachable\nfrom a branch, but still there (but don't play with \"git gc\" until\nyou're sure you've recovered all of it...). \"git reflog\" should give\nyou the sha1 of the commit you're looking for (if you didn't really\nmess up everything, you really look for just one commit, which is the\ntip of the sequence of commits you did while on a detached HEAD, that\nis, the one just before you did \"git checkout master\".\n\nThen, do\n\ngit branch tmp <the-sha1-you-found>\n(possibly run \"gitk --all\" to understand, here)\ngit merge tmp\n\nto create a branch named tmp containing your commits, and merge it\ninto your current branch. Naming the branch isn't strictly necessary,\nbut will help in case you do anything wrong trying to merge.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"139594","messageId":"v2r62a3a9cb1004150729v1e0a60bq381bc382f76f3c27@mail.gmail.com","threadId":"23478","inReplyTo":"vpqtyrc6bse.fsf@bauges.imag.fr","subject":"Re: Lost a week?","fromName":"Daniel Grace","fromEmail":"negativeview@gmail.com","sentAt":"2010-04-15T14:29:26Z","receivedAt":"2010-04-15T14:29:26Z","isPatch":false,"sender":{"key":"negativeview@gmail.com","avatar":"https://gravatar.com/avatar/3cdfd055fcddbe166daf37ce403bfce216b100e8fc783998f43938ff77c388dc?d=mp&s=160"},"body":"Thanks everyone! I had heard the phrase \"detached head\" before, but\ndidn't really understand what it is. I'm glad to note that all my\ncommits were there. I wasn't really worried, I knew that git had\nstored it dutifully away SOMEWHERE.\n\nI have that page bookmarked now Thomas. Unfortunately I have customer\nwork to do now that I am not missing work, but I promise to read and\nunderstand it fully as soon as I'm done with that.\n\nDaniel\nhttp://www.doomstick.com\n\n\n\nOn Thu, Apr 15, 2010 at 9:16 AM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Daniel Grace <negativeview@gmail.com> writes:\n>\n>> github shows the same. I KNOW that there were commits (representing a\n>> good bit of work) in that time. I'm sure that it's *somewhere* but I'm\n>> at a complete loss as to where it is. gitk shows no side branches (nor\n>> does git branch). I don't use branches really, as much as I know that\n>> I should.\n>\n> I guess you've been on a detached HEAD for some time. Recent version\n> of Git warn you this way when you enter in this state:\n>\n> ,----\n> | Note: checking out 'HEAD^'.\n> |\n> | You are in 'detached HEAD' state. You can look around, make experimental\n> | changes and commit them, and you can discard any commits you make in this\n> | state without impacting any branches by performing another checkout.\n> |\n> | If you want to create a new branch to retain commits you create, you may\n> | do so (now or later) by using -b with the checkout command again. Example:\n> |\n> |   git checkout -b new_branch_name\n> |\n> | HEAD is now at a8e7ba9... foo\n> `----\n>\n> Now, your changes are probably not lost forever: they're not reachable\n> from a branch, but still there (but don't play with \"git gc\" until\n> you're sure you've recovered all of it...). \"git reflog\" should give\n> you the sha1 of the commit you're looking for (if you didn't really\n> mess up everything, you really look for just one commit, which is the\n> tip of the sequence of commits you did while on a detached HEAD, that\n> is, the one just before you did \"git checkout master\".\n>\n> Then, do\n>\n> git branch tmp <the-sha1-you-found>\n> (possibly run \"gitk --all\" to understand, here)\n> git merge tmp\n>\n> to create a branch named tmp containing your commits, and merge it\n> into your current branch. Naming the branch isn't strictly necessary,\n> but will help in case you do anything wrong trying to merge.\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n>\n"}]}