Bob
Bob

Reputation: 1455

Create an annotated git-tag with a particular tagger-name, tagged-date

How to create an annotated git-tag with a particular tagger-name, tagged-date?

The docs how to make it right have no such info.

From another stackoverflow question:

git config --global user.name "John Doe"
git config --global user.email [email protected]
git tag <tag-name> [commit]
git push origin <tag-name>

I have to redefine global config settings - well this is clearly not a good way

Upvotes: 1

Views: 270

Answers (2)

Bob
Bob

Reputation: 1455

The simple and CORRECT solution would be:

$ git mktag <tag-file >output

tag-file:

object <HASH>  # hash of the commit we are want to set tag to
type commit
tag <NAME>  # name of the tag
tagger Bob Dylan <[email protected]> 1484015966 +0000

Message

output:

<HASH>  # hash of the created tag

after:

$ git update-ref refs/tags/<NAME of the created tag> <the HASH from output file>

Upvotes: 2

iBug
iBug

Reputation: 37217

An annotated tag is very similar to a commit, and thus methods for git commit works for git tag -a.

  • For specifying date, use GIT_COMMITTER_DATE and GIT_AUTHOR_DATE environment variables.
  • For temporarily (for this single command only) changing git config, use git -c config_key=config.value

So the command you can do is:

GIT_COMMITTER_DATE="1970-01-01T00:00:00Z" \
GIT_AUTHOR_DATE="1970-01-01T00:00:00Z" \
  git -c user.name='Jeff Atwood' \
      -c [email protected] \
      tag -a 1234abc

Upvotes: 3

Related Questions