# how can we git out source code base on git log?

3 messages from 2011-03-07 to 2011-03-08. Participants: loody, Jeff King, Matthieu Moy.
Thread: https://gitlist.dev/t/26685

## loody, 2011-03-07 17:25

Subject: how can we git out source code base on git log?
Message-ID: <AANLkTimAPBoHJX0iZOt949xQ8HeGPXRyKfD4CDNJFv7u@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimAPBoHJX0iZOt949xQ8HeGPXRyKfD4CDNJFv7u%40mail.gmail.com

```
Dear all:
There is a paragraph in faq which told us how to git out some specific tag.

But how could I check out the source at some specific point of time if
I have no idea what the tag is or there is no tag on it.

Below I use uboot for example:

commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0
Author: Mikhail Zolotaryov <lebon@lebon.org.ua>
Date:   Wed Sep 8 17:06:03 2010 +0300
.......
.......

commit b75a2dde47cc0ffb686e21cbf1aea4a45e23df10
Author: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
Date:   Mon Oct 11 18:03:35 2010 +0200
    tools/imls: fix comment in Makefile

Is it possible I can check out the commit as
3831530dcb7b71329c272ccd6181f8038b6a6dd0,?

Meanwhile, is there any command can help me to get the history that
combine tag and commit such that I can know know the closest tag of
some specific commit?

take below for example, I will know ccdd is the closest tag of commit
b75a2dde47cc0ffb686e21cbf1aea4a45e23df10.


commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0
Author: Mikhail Zolotaryov <lebon@lebon.org.ua>
Date:   Wed Sep 8 17:06:03 2010 +0300
.......
.......

Tag: aabb

commit b75a2dde47cc0ffb686e21cbf1aea4a45e23df10
Author: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
Date:   Mon Oct 11 18:03:35 2010 +0200
    tools/imls: fix comment in Makefile
......

Tag: ccdd


-- 
Regards,

miloody

```

## Jeff King, 2011-03-07 18:32

Subject: Re: how can we git out source code base on git log?
Message-ID: <20110307183210.GB20411@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20110307183210.GB20411%40sigill.intra.peff.net
In-Reply-To: <AANLkTimAPBoHJX0iZOt949xQ8HeGPXRyKfD4CDNJFv7u@mail.gmail.com>

```
On Tue, Mar 08, 2011 at 01:25:53AM +0800, loody wrote:

> Below I use uboot for example:
> 
> commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0
> Author: Mikhail Zolotaryov <lebon@lebon.org.ua>
> Date:   Wed Sep 8 17:06:03 2010 +0300
>
> [...]
>
> Is it possible I can check out the commit as
> 3831530dcb7b71329c272ccd6181f8038b6a6dd0,?

Yes, just do "git checkout 3831530d" (you don't need to use the whole
id; any prefix that is unique within the repository is enough).

> Meanwhile, is there any command can help me to get the history that
> combine tag and commit such that I can know know the closest tag of
> some specific commit?
> 
> take below for example, I will know ccdd is the closest tag of commit
> b75a2dde47cc0ffb686e21cbf1aea4a45e23df10.

Yes:

  $ git describe b75a2dde
  v2010.09-250-gb75a2dd

This means that the commit is 250 commits past v2010.09. If you want to
know which tags already have the commit, try:

  $ git describe --contains b75a2dde
  v2010.12-rc1~126

which means it is inside v2010.12-rc1, and it is 126 commits back
(following each commit's first parent).

You may also want to know all tags that contain it:

  $ git tag --contains b75a2dde
  v2010.12
  v2010.12-rc1
  v2010.12-rc2
  v2010.12-rc3
  v2011.03-rc1

See "git help describe" for more information.

-Peff

```

## Matthieu Moy, 2011-03-08 08:22

Subject: Re: how can we git out source code base on git log?
Message-ID: <vpq8vwqvx65.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpq8vwqvx65.fsf%40bauges.imag.fr
In-Reply-To: <AANLkTimAPBoHJX0iZOt949xQ8HeGPXRyKfD4CDNJFv7u@mail.gmail.com>

```
loody <miloody@gmail.com> writes:

> Is it possible I can check out the commit as
> 3831530dcb7b71329c272ccd6181f8038b6a6dd0,?

In complement to Jeff's answer: you can also get the content of a
specific file without checking out with

  git show 3831530dcb7b713:path/to/file

> commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0
> Author: Mikhail Zolotaryov <lebon@lebon.org.ua>
> Date:   Wed Sep 8 17:06:03 2010 +0300
> .......
> .......
>
> Tag: aabb

  git log --decorate

does this (except that tags appear after the commit ID, not after the
log message). You may also want to look at gitk.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```
