3

git checkout - checks out the previously checked out commit reference. Where is this information stored, and is there a similar way to access any nth previously checked out commit?

I would like to be able to look at a list of the references I've checked out (particularly as opposed to looking at every available branch) so that I can easily find the branches I've worked on locally. Obviously, this situation only occurs with large, multi user repositories.

bschlueter
  • 3,817
  • 1
  • 30
  • 48

2 Answers2

1

git checkout @{-N}

From the man page: http://git-scm.com/docs/git-checkout

As a special case, the "@{-N}" syntax for the N-th last branch/commit checks out branches (instead of detaching). You may also specify - which is synonymous with "@{-1}".

NightShadeQueen
  • 3,284
  • 3
  • 24
  • 37
  • @bschlueter Incidentally, that part of the doc has just slightly changed: see https://stackoverflow.com/a/47839400/6309 – VonC Dec 15 '17 at 20:27
-2

If you want to checkout some of the previous versions, you need to find version hash using command

 git log --oneline

It will list all your older commits:

 ac7dfd7 Bumped version number of exception chains dependency
 0390d4c Changed target to match project name in proxy object
 4beef4e updated docs
 de07e72 Merge branch 'master' of github.com:ucam-cl-dtg/resteasy-api-example
 39653ff ignore ~ files
 c7fd3fb initial check in
 427783d initial gitignore file
 bbe1aba Initial commit

Now you can select which one you want to checkout:

git checkout 39653ff

I hope that was what you are looking for.

Zoran

zoran jeremic
  • 2,046
  • 4
  • 21
  • 47
  • I'm certainly not interested in just seeing log information based on my question. As with @madyx's answer, this also only provides information about relative commits, not recently checked out references. – bschlueter Jun 30 '15 at 02:38