# [BugReport] git tag -a / git show

9 messages from 2012-02-24 to 2012-02-24. Participants: Romain Vimont (®om), Zbigniew Jędrzejewski-Szmek, Junio C Hamano, Jeff King, Andreas Schwab.
Thread: https://gitlist.dev/t/29722

## Romain Vimont (®om), 2012-02-24 10:24

Subject: [BugReport] git tag -a / git show
Message-ID: <b05f03b381140ca57a7d03a934f605bd@rom1v.com>
URL: https://gitlist.dev/e/b05f03b381140ca57a7d03a934f605bd%40rom1v.com

```
$ git --version
git version 1.7.5.4

$ git log --pretty=online
0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff This is the last commit
a4702c69c28484d357179166cf3b116764da20a4 This is a commit

Now, I edit some files (for example in a config file "mock_data=true"), 
then I want to tag without commiting this change.

$ git tag -a v0.1 -m 'My v0.1 with mock data'

$ git show v0.1
tag v0.1
Tagger: Me <me@me.me>
Date:   Fri Feb 24 11:23:38 2012 +0100

     My v0.1 with mock data

commit 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff
Author: Me <me@me.me>
Date:   Fri Feb 24 11:14:19 2012 +0100

     This is the last commit

diff --git a/myfile b/myfile
index 8430bf6..20feeb6 100644
...


And it shows the diff between a4702c69c28484d357179166cf3b116764da20a4 
and 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the two last commits).
Instead, it should show the diff between 
0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the last commit) and v0.1 (the 
tag).

Best regards,
®om

```

## Zbigniew Jędrzejewski-Szmek, 2012-02-24 19:27

Subject: Re: [BugReport] git tag -a / git show
Message-ID: <4F47E48D.4080501@in.waw.pl>
URL: https://gitlist.dev/e/4F47E48D.4080501%40in.waw.pl
In-Reply-To: <b05f03b381140ca57a7d03a934f605bd@rom1v.com>

```
On 02/24/2012 11:24 AM, Romain Vimont (®om) wrote:
> $ git log --pretty=online
> 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff This is the last commit
> a4702c69c28484d357179166cf3b116764da20a4 This is a commit
>
> Now, I edit some files (for example in a config file "mock_data=true"),
> then I want to tag without commiting this change.
>
> $ git tag -a v0.1 -m 'My v0.1 with mock data'

> And it shows the diff between a4702c69c28484d357179166cf3b116764da20a4
> and 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the two last commits).

Hi Romain,
git tag attaches the tag to the last commit, 0ef41513 in your case. 
Dirty changes in your tree are ignored by the tag command. You would 
have to commit them first, and attach the tag to this new commit.

zbyszek

```

## Junio C Hamano, 2012-02-24 19:50

Subject: Re: [Not A BugReport] git tag -a / git show
Message-ID: <7vsji0yprw.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vsji0yprw.fsf%40alter.siamese.dyndns.org
In-Reply-To: <b05f03b381140ca57a7d03a934f605bd@rom1v.com>

```
"Romain Vimont (®om)" <rom@rom1v.com> writes:

> Now, I edit some files (for example in a config file
> "mock_data=true"), then I want to tag without commiting this change.

Tag applies to an existing commit [*1*].  Your change in the working tree
is purely ephemeral until it is committed.

In other words, you don't "tag without committing".

> $ git tag -a v0.1 -m 'My v0.1 with mock data'

By omitting the [<head>] part from your command line for a command whose
usage is:

  usage: git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]

you asked <head> to default to HEAD, the most recent commit, so the tag
points at your 0ef41513d0b6 (This is the last commit).  The tag message
should say "My v0.1" without anything else.

And show naturally shows the patch to bring its parent to that tagged
commit.

If you wanted to keep your mainline pristine without mock data, and want
to have a playpen that uses mock data, a way to do so is to use a separate
branch, e.g.

        $ git checkout -b playpen

Now, you are on your 'playpen' branch that was forked from the tip of
whatever branch you were on, perhaps 'master'.  Then commit that state
with whatever change that is specific to the playpen you want to keep out
of the mainline:

	$ edit config.txt ;# set mock_data=true
        $ git commit -a -m 'With mock data'

You can optionally tag the resulting commit if you want to.  You are still
on the 'playpen' branch, so you probably would want to come back to the
previous branch after you are done.


[Footnote]

*1* technically, tag can apply to any type of object, but it is most
common to apply to a commit.

```

## Romain Vimont (®om), 2012-02-24 19:55

Subject: Re: [BugReport] git tag -a / git show
Message-ID: <1330113345.2727.3.camel@rom-laptop>
URL: https://gitlist.dev/e/1330113345.2727.3.camel%40rom-laptop
In-Reply-To: <4F47E48D.4080501@in.waw.pl>

```
Thank you for your answer.

After my message this morning, that's what I did: I commited with the
mock data then tag.

Tonight, I just tried something which do exactly what I wanted to do
this morning:

$ git checkout -b temp
$ git commit -a -m 'My config file with mock_data=true'
$ git tag -a v0.1 -m v0.1
$ git checkout master
$ git branch -D temp

With these commands, the tag is associated to a commit which is not in
any branch.

Regards,
©om

Le vendredi 24 février 2012 à 20:27 +0100, Zbigniew Jędrzejewski-Szmek a
écrit :
> On 02/24/2012 11:24 AM, Romain Vimont (®om) wrote:
> > $ git log --pretty=online
> > 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff This is the last commit
> > a4702c69c28484d357179166cf3b116764da20a4 This is a commit
> >
> > Now, I edit some files (for example in a config file "mock_data=true"),
> > then I want to tag without commiting this change.
> >
> > $ git tag -a v0.1 -m 'My v0.1 with mock data'
> 
> > And it shows the diff between a4702c69c28484d357179166cf3b116764da20a4
> > and 0ef41513d0b6d0ad28f21d0ac1da7096ad1dc6ff (the two last commits).
> 
> Hi Romain,
> git tag attaches the tag to the last commit, 0ef41513 in your case. 
> Dirty changes in your tree are ignored by the tag command. You would 
> have to commit them first, and attach the tag to this new commit.
> 
> zbyszek
> 

```

## Romain Vimont (®om), 2012-02-24 19:58

Subject: Re: [Not A BugReport] git tag -a / git show
Message-ID: <1330113528.2727.5.camel@rom-laptop>
URL: https://gitlist.dev/e/1330113528.2727.5.camel%40rom-laptop
In-Reply-To: <7vsji0yprw.fsf@alter.siamese.dyndns.org>

```
Thank you for the details.

> *1* technically, tag can apply to any type of object, but it is most
common to apply to a commit.

To what other type of object can you apply a tag ?

Good evening.

Le vendredi 24 février 2012 à 11:50 -0800, Junio C Hamano a écrit :
> "Romain Vimont (®om)" <rom@rom1v.com> writes:
> 
> > Now, I edit some files (for example in a config file
> > "mock_data=true"), then I want to tag without commiting this change.
> 
> Tag applies to an existing commit [*1*].  Your change in the working tree
> is purely ephemeral until it is committed.
> 
> In other words, you don't "tag without committing".
> 
> > $ git tag -a v0.1 -m 'My v0.1 with mock data'
> 
> By omitting the [<head>] part from your command line for a command whose
> usage is:
> 
>   usage: git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]
> 
> you asked <head> to default to HEAD, the most recent commit, so the tag
> points at your 0ef41513d0b6 (This is the last commit).  The tag message
> should say "My v0.1" without anything else.
> 
> And show naturally shows the patch to bring its parent to that tagged
> commit.
> 
> If you wanted to keep your mainline pristine without mock data, and want
> to have a playpen that uses mock data, a way to do so is to use a separate
> branch, e.g.
> 
>         $ git checkout -b playpen
> 
> Now, you are on your 'playpen' branch that was forked from the tip of
> whatever branch you were on, perhaps 'master'.  Then commit that state
> with whatever change that is specific to the playpen you want to keep out
> of the mainline:
> 
> 	$ edit config.txt ;# set mock_data=true
>         $ git commit -a -m 'With mock data'
> 
> You can optionally tag the resulting commit if you want to.  You are still
> on the 'playpen' branch, so you probably would want to come back to the
> previous branch after you are done.
> 
> 
> [Footnote]
> 
> *1* technically, tag can apply to any type of object, but it is most
> common to apply to a commit.
> 

```

## Jeff King, 2012-02-24 20:52

Subject: Re: [BugReport] git tag -a / git show
Message-ID: <20120224205203.GA21780@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120224205203.GA21780%40sigill.intra.peff.net
In-Reply-To: <1330113345.2727.3.camel@rom-laptop>

```
On Fri, Feb 24, 2012 at 08:55:45PM +0100, Romain Vimont (®om) wrote:

> Tonight, I just tried something which do exactly what I wanted to do
> this morning:
> 
> $ git checkout -b temp
> $ git commit -a -m 'My config file with mock_data=true'
> $ git tag -a v0.1 -m v0.1
> $ git checkout master
> $ git branch -D temp

There is nothing at all wrong with the commands above, but you might be
interested to know that you can do it without the temporary branch:

  $ git commit -a -m 'My config...'
  $ git tag -m v0.1 v0.1
  $ git reset HEAD^

The final reset will rewind your branch tip and the index state to what
it was before the commit, but will leave the files in the working tree
untouched.

-Peff

```

## Romain Vimont (®om), 2012-02-24 21:42

Subject: Re: [BugReport] git tag -a / git show
Message-ID: <1330119763.2727.10.camel@rom-laptop>
URL: https://gitlist.dev/e/1330119763.2727.10.camel%40rom-laptop
In-Reply-To: <20120224205203.GA21780@sigill.intra.peff.net>

```
Thank you, I didn't know this '^' thing ;-)

Le vendredi 24 février 2012 à 15:52 -0500, Jeff King a écrit :
> On Fri, Feb 24, 2012 at 08:55:45PM +0100, Romain Vimont (®om) wrote:
> 
> > Tonight, I just tried something which do exactly what I wanted to do
> > this morning:
> > 
> > $ git checkout -b temp
> > $ git commit -a -m 'My config file with mock_data=true'
> > $ git tag -a v0.1 -m v0.1
> > $ git checkout master
> > $ git branch -D temp
> 
> There is nothing at all wrong with the commands above, but you might be
> interested to know that you can do it without the temporary branch:
> 
>   $ git commit -a -m 'My config...'
>   $ git tag -m v0.1 v0.1
>   $ git reset HEAD^
> 
> The final reset will rewind your branch tip and the index state to what
> it was before the commit, but will leave the files in the working tree
> untouched.
> 
> -Peff
> 

```

## Jeff King, 2012-02-24 21:44

Subject: Re: [BugReport] git tag -a / git show
Message-ID: <20120224214428.GA16828@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120224214428.GA16828%40sigill.intra.peff.net
In-Reply-To: <1330119763.2727.10.camel@rom-laptop>

```
On Fri, Feb 24, 2012 at 10:42:43PM +0100, Romain Vimont (®om) wrote:

> Thank you, I didn't know this '^' thing ;-)

You might find the "Specifying Revisions" section of "git help
rev-parse" enlightening. :)

-Peff

```

## Andreas Schwab, 2012-02-24 23:14

Subject: Re: [Not A BugReport] git tag -a / git show
Message-ID: <m2fwdzzuw0.fsf@igel.home>
URL: https://gitlist.dev/e/m2fwdzzuw0.fsf%40igel.home
In-Reply-To: <1330113528.2727.5.camel@rom-laptop>

```
Romain Vimont "(®om)" <rom@rom1v.com> writes:

> To what other type of object can you apply a tag ?

Any.  Take a look at the junio-gpg-pub tag in git's repository, or the
v2.6.11-tree tag in Linus's kernel repository.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```
