# Is it possible get the tag name of working copy in Git?

3 messages from 2015-03-13 to 2015-03-13. Participants: chen chang, Torsten Bögershausen, Stefan Beller.
Thread: https://gitlist.dev/t/38793

## chen chang, 2015-03-13 07:08

Subject: Is it possible get the tag name of working copy in Git?
Message-ID: <CAFL7HFUNMrTfLx+kj6rBiNeuLhbkPF_t32kOYYSxBP9F=eKSxQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAFL7HFUNMrTfLx%2Bkj6rBiNeuLhbkPF_t32kOYYSxBP9F%3DeKSxQ%40mail.gmail.com

```
I want to use make file auto generate the revision number of working
copy from the tag name in git.
So as questioned in subject, I have tried to use 'git describe', it
works well in most case, and the output is good match my requirement.
Problem is: when there are multiple tags on same one commit, if check
out one of these tag, the 'git describe' only be able to return the
most new created tag name in that commit, instead of the real checked
out tag.

Seems 'git-describe' capture the most recent tag name by create sequence.

I expect add an argument to 'git-describe' to make it get the most
recent tag name according to checkout status when multiple tags on one
commit.

Is there any suggestion? Thanks!

------------------------------
Chen Chang

```

## Torsten Bögershausen, 2015-03-13 09:36

Subject: Re: Is it possible get the tag name of working copy in Git?
Message-ID: <5502AF86.9050803@web.de>
URL: https://gitlist.dev/e/5502AF86.9050803%40web.de
In-Reply-To: <CAFL7HFUNMrTfLx+kj6rBiNeuLhbkPF_t32kOYYSxBP9F=eKSxQ@mail.gmail.com>

```
On 03/13/2015 08:08 AM, chen chang wrote:
> I want to use make file auto generate the revision number of working
> copy from the tag name in git.
You should have the tag name, as it is set up before running make,
and probably feed into both "git checkout tagXXYYXX" and the Makefile.

If you want the "version number", what is this ?
Git has a sha value, you can git it like this:

git rev-parse HEAD  | cut -b 1-9

HTH

```

## Stefan Beller, 2015-03-13 17:00

Subject: Re: Is it possible get the tag name of working copy in Git?
Message-ID: <CAGZ79kaeWkVD-tCVMRYBxgG80_PHOeHKeSdpodAPqgpdiARa7Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kaeWkVD-tCVMRYBxgG80_PHOeHKeSdpodAPqgpdiARa7Q%40mail.gmail.com
In-Reply-To: <5502AF86.9050803@web.de>

```
On Fri, Mar 13, 2015 at 2:36 AM, Torsten Bögershausen <tboegi@web.de> wrote:
> On 03/13/2015 08:08 AM, chen chang wrote:
>>
>> I want to use make file auto generate the revision number of working
>> copy from the tag name in git.
>

Maybe you're looking for git describe?
http://git-scm.com/docs/git-describe

```
