threads / discuss / 38793

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

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

## tl;dr

3 messages between Mar 13, 2015 and Mar 13, 2015.

replies: 2people: 3as markdown or json

chen chang· Mar 13, 2015, 07:08 UTC · lore

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· Mar 13, 2015, 09:36 UTC · re: chen chang · lore

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

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· Mar 13, 2015, 17:00 UTC · re: Torsten Bögershausen · lore

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

On Fri, Mar 13, 2015 at 2:36 AM, Torsten Bögershausen <tboegi@web.de> wrote:
Show 5 quoted lines
> 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

← back to recent threads