# checkout to a reflog entry

3 messages from 2009-08-25 to 2009-08-25. Participants: bill lam, Jeff King.
Thread: https://gitlist.dev/t/20726

## bill lam, 2009-08-25 04:52

Subject: checkout to a reflog entry
Message-ID: <20090825045235.GB391@debian.b2j>
URL: https://gitlist.dev/e/20090825045235.GB391%40debian.b2j

```
Sometimes when git reflog and try to checkout to a previous commit, 

project((6a33dbc...))$ git reflog show master
77aa688 master@{0}: rebase -i (finish): refs/heads/master onto fc3eaa4
6a33dbc master@{1}: commit: wip
.....


project(master)$ git checkout master@{1}
Note: moving to 'master@{1}' which isn't a local branch
If you want to create a new branch from this checkout, 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 6a33dbc... wip
project((6a33dbc...))$ 

project((6a33dbc...))$ git branch
* (no branch)
  master

It becomes (no branch) although the SHA1 is correct. If I then checkout master,
then it revert and jump back up the previous master HEAD.  I tried HEAD@{xx}
also failed.  What is the correct way of to checkout that master@{..} and stay
in that master branch?  (Sometimes it worked I forgot how and why)

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```

## Jeff King, 2009-08-25 05:22

Subject: Re: checkout to a reflog entry
Message-ID: <20090825052200.GA15880@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090825052200.GA15880%40coredump.intra.peff.net
In-Reply-To: <20090825045235.GB391@debian.b2j>

```
On Tue, Aug 25, 2009 at 12:52:35PM +0800, bill lam wrote:

> project(master)$ git checkout master@{1}
> Note: moving to 'master@{1}' which isn't a local branch
> [...]
> It becomes (no branch) although the SHA1 is correct. If I then
> checkout master, then it revert and jump back up the previous master
> HEAD.  I tried HEAD@{xx} also failed.  What is the correct way of to
> checkout that master@{..} and stay in that master branch?  (Sometimes
> it worked I forgot how and why)

A reflog entry is not a branch; it is just a pointer to the commit where
a branch was at some point. Using "git checkout" on it will let you
explore the contents, just as you might with a tag. If you want to build
on it, you need to either:

  1. Make a new branch to work on, starting at that point:

       git checkout -b my-topic master@{1}

  2. Reset your current branch (and worktree) to point at that commit:

       git reset --hard master@{1}

-Peff

```

## bill lam, 2009-08-25 05:37

Subject: Re: checkout to a reflog entry
Message-ID: <20090825053747.GC391@debian.b2j>
URL: https://gitlist.dev/e/20090825053747.GC391%40debian.b2j
In-Reply-To: <20090825052200.GA15880@coredump.intra.peff.net>

```
On Tue, 25 Aug 2009, Jeff King wrote:
> A reflog entry is not a branch; it is just a pointer to the commit where
> a branch was at some point. Using "git checkout" on it will let you
> explore the contents, just as you might with a tag. If you want to build

Thank you for explanation on the difference between checkout and
reset.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```
