{"thread":{"id":"24233","subject":"recovering orphaned commit","startedAt":"2010-06-29T15:09:03Z","lastAt":"2010-06-29T15:29:18Z","messageCount":5,"participants":["Mahesh Vaidya","Jonathan Nieder","Ramkumar Ramachandra","Shawn O. Pearce","Wincent Colaiuta"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144462","messageId":"AANLkTiks6yPfdTACQwZlqv8PPPEg3RYGMx1Q1PjT0nRu@mail.gmail.com","threadId":"24233","inReplyTo":null,"subject":"recovering orphaned commit","fromName":"Mahesh Vaidya","fromEmail":"forvaidya@gmail.com","sentAt":"2010-06-29T15:09:03Z","receivedAt":"2010-06-29T15:09:03Z","isPatch":false,"sender":{"key":"forvaidya@gmail.com","avatar":null},"body":" I have a situation like this; 2 commits.\n\nExample -\n\n 2899684ed173063354b7fe4f5ec7216e7d953e2c\t <-- HEAD  ( say C1)\n 1ef67de1a0d6e97470a8c827d2989317600532ff                    ( say C2)\n\nTo see file at C2 ; I have done git reset --hard C2; I could see the file.\nNow want go to C1 ; Ho do I Determine C1  using git command ?\n\nThx/ Mahesh Bangalore India.\n"},{"id":"144465","messageId":"20100629151716.GF2337@spearce.org","threadId":"24233","inReplyTo":"AANLkTiks6yPfdTACQwZlqv8PPPEg3RYGMx1Q1PjT0nRu@mail.gmail.com","subject":"Re: recovering orphaned commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-06-29T15:17:16Z","receivedAt":"2010-06-29T15:17:16Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Mahesh Vaidya <forvaidya@gmail.com> wrote:\n>  I have a situation like this; 2 commits.\n> \n> Example -\n> \n>  2899684ed173063354b7fe4f5ec7216e7d953e2c\t <-- HEAD  ( say C1)\n>  1ef67de1a0d6e97470a8c827d2989317600532ff                    ( say C2)\n> \n> To see file at C2 ; I have done git reset --hard C2; I could see the file.\n> Now want go to C1 ; Ho do I Determine C1  using git command ?\n\nUse `git reflog show` or `git log -g` to view the reflog entries\nfor HEAD.  It will show you the different states HEAD had, so you\nwant to find the state before you reset to C2, that would be C1.\n\n-- \nShawn.\n"},{"id":"144464","messageId":"20100629152424.GE4724@debian","threadId":"24233","inReplyTo":"AANLkTiks6yPfdTACQwZlqv8PPPEg3RYGMx1Q1PjT0nRu@mail.gmail.com","subject":"Re: recovering orphaned commit","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-06-29T15:24:24Z","receivedAt":"2010-06-29T15:24:24Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Mahesh,\n\nMahesh Vaidya writes:\n>  I have a situation like this; 2 commits.\n> \n> Example -\n> \n>  2899684ed173063354b7fe4f5ec7216e7d953e2c\t <-- HEAD  ( say C1)\n>  1ef67de1a0d6e97470a8c827d2989317600532ff                    ( say C2)\n> \n> To see file at C2 ; I have done git reset --hard C2; I could see the file.\n> Now want go to C1 ; Ho do I Determine C1  using git command ?\n\nUse git-reflog (1) perhaps?\n\n-- Ram\n"},{"id":"144463","messageId":"20100629152606.GA7202@burratino","threadId":"24233","inReplyTo":"AANLkTiks6yPfdTACQwZlqv8PPPEg3RYGMx1Q1PjT0nRu@mail.gmail.com","subject":"Re: recovering orphaned commit","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-29T15:26:06Z","receivedAt":"2010-06-29T15:26:06Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Mahesh,\n\nMahesh Vaidya wrote:\n\n>  2899684ed173063354b7fe4f5ec7216e7d953e2c\t <-- HEAD  ( say C1)\n>  1ef67de1a0d6e97470a8c827d2989317600532ff                    ( say C2)\n> \n> To see file at C2 ; I have done git reset --hard C2\n\nFor the future, ‘git checkout C2’ might work better for this task.\nUnlike ‘git reset’, it does not change where the current branch head\npoints, so when you’re done exploring you can get back to where you\nwere with ‘git checkout topic’ (where topic is the name of the branch\n--- e.g., master).\n\n> Now want go to C1 ; Ho do I Determine C1  using git command ?\n\ngit log -g HEAD\n\nHope that helps,\nJonathan\n"},{"id":"144471","messageId":"A91ACF1D-6773-4EDA-98F5-DD6F993577CB@wincent.com","threadId":"24233","inReplyTo":"AANLkTiks6yPfdTACQwZlqv8PPPEg3RYGMx1Q1PjT0nRu@mail.gmail.com","subject":"Re: recovering orphaned commit","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2010-06-29T15:29:18Z","receivedAt":"2010-06-29T15:29:18Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 29/06/2010, a las 17:09, Mahesh Vaidya escribió:\n\n> I have a situation like this; 2 commits.\n> \n> Example -\n> \n> 2899684ed173063354b7fe4f5ec7216e7d953e2c\t <-- HEAD  ( say C1)\n> 1ef67de1a0d6e97470a8c827d2989317600532ff                    ( say C2)\n> \n> To see file at C2 ; I have done git reset --hard C2; I could see the file.\n\n\"git reset --hard\" isn't really intended as a tool for inspecting files in other revisions. Didn't the \"--hard\" switch suggest that you were about to do something potentially dangerous? (The danger here, as noted in the manpage, is that you will lose any uncommitted changes that might be in the working tree.)\n\n\"git show REV:FILE\" could be used to inspect the state of FILE as it was in commit REV.\n\nIf you just want to snoop around the tree you could also just checkout the revision (\"git checkout REV\") and when you're done go back to your old HEAD (\"git checkout master\" or whatever branch you were on).\n\nYou could also try using \"gitk\" for general point-and-click snooping around over revisions and trees.\n\n> Now want go to C1 ; Ho do I Determine C1  using git command ?\n\nWell, even though you overwrote the old value of HEAD, it is still in the reflog, which you can inspect with \"git reflog\".\n\nAnd if you just want to actually put the HEAD back the way it was before, you could use \"git reset\" again (ie. \"git reset C1\"). As the man page says, the \"--hard\" switch here will not only update the HEAD, but also update the contents of the working tree to match it.\n\nCheers,\nWincent\n"}]}