git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Not A BugReport] git tag -a / git show

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 24, 2012, 19:50 UTC
Message-ID
<7vsji0yprw.fsf@alter.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.

Previous: Jeff KingNext: Romain Vimont (®om)
Message 7 of 9 in “[BugReport] git tag -a / git show”
  1. Romain Vimont (®om)Feb 24, 2012
  2. Zbigniew Jędrzejewski-SzmekFeb 24, 2012
  3. Romain Vimont (®om)Feb 24, 2012
  4. Jeff KingFeb 24, 2012
  5. Romain Vimont (®om)Feb 24, 2012
  6. Jeff KingFeb 24, 2012
  7. Junio C HamanoFeb 24, 2012
  8. Romain Vimont (®om)Feb 24, 2012
  9. Andreas SchwabFeb 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.