{"thread":{"id":"20726","subject":"checkout to a reflog entry","startedAt":"2009-08-25T04:52:35Z","lastAt":"2009-08-25T05:37:47Z","messageCount":3,"participants":["bill lam","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"121704","messageId":"20090825045235.GB391@debian.b2j","threadId":"20726","inReplyTo":null,"subject":"checkout to a reflog entry","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-08-25T04:52:35Z","receivedAt":"2009-08-25T04:52:35Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"Sometimes when git reflog and try to checkout to a previous commit, \n\nproject((6a33dbc...))$ git reflog show master\n77aa688 master@{0}: rebase -i (finish): refs/heads/master onto fc3eaa4\n6a33dbc master@{1}: commit: wip\n.....\n\n\nproject(master)$ git checkout master@{1}\nNote: moving to 'master@{1}' which isn't a local branch\nIf you want to create a new branch from this checkout, you may do so\n(now or later) by using -b with the checkout command again. Example:\n  git checkout -b <new_branch_name>\nHEAD is now at 6a33dbc... wip\nproject((6a33dbc...))$ \n\nproject((6a33dbc...))$ git branch\n* (no branch)\n  master\n\nIt becomes (no branch) although the SHA1 is correct. If I then checkout master,\nthen it revert and jump back up the previous master HEAD.  I tried HEAD@{xx}\nalso failed.  What is the correct way of to checkout that master@{..} and stay\nin that master branch?  (Sometimes it worked I forgot how and why)\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n"},{"id":"121709","messageId":"20090825052200.GA15880@coredump.intra.peff.net","threadId":"20726","inReplyTo":"20090825045235.GB391@debian.b2j","subject":"Re: checkout to a reflog entry","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-25T05:22:01Z","receivedAt":"2009-08-25T05:22:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 25, 2009 at 12:52:35PM +0800, bill lam wrote:\n\n> project(master)$ git checkout master@{1}\n> Note: moving to 'master@{1}' which isn't a local branch\n> [...]\n> It becomes (no branch) although the SHA1 is correct. If I then\n> checkout master, then it revert and jump back up the previous master\n> HEAD.  I tried HEAD@{xx} also failed.  What is the correct way of to\n> checkout that master@{..} and stay in that master branch?  (Sometimes\n> it worked I forgot how and why)\n\nA reflog entry is not a branch; it is just a pointer to the commit where\na branch was at some point. Using \"git checkout\" on it will let you\nexplore the contents, just as you might with a tag. If you want to build\non it, you need to either:\n\n  1. Make a new branch to work on, starting at that point:\n\n       git checkout -b my-topic master@{1}\n\n  2. Reset your current branch (and worktree) to point at that commit:\n\n       git reset --hard master@{1}\n\n-Peff\n"},{"id":"121711","messageId":"20090825053747.GC391@debian.b2j","threadId":"20726","inReplyTo":"20090825052200.GA15880@coredump.intra.peff.net","subject":"Re: checkout to a reflog entry","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-08-25T05:37:47Z","receivedAt":"2009-08-25T05:37:47Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"On Tue, 25 Aug 2009, Jeff King wrote:\n> A reflog entry is not a branch; it is just a pointer to the commit where\n> a branch was at some point. Using \"git checkout\" on it will let you\n> explore the contents, just as you might with a tag. If you want to build\n\nThank you for explanation on the difference between checkout and\nreset.\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n"}]}