LinuxCommandLibrary

git-mktag

Create a tag object

SYNOPSIS

git mktag < tag-definition

DESCRIPTION

git-mktag is a low-level plumbing command in Git that reads a tag object definition from standard input and produces the corresponding tag object in binary format on standard output. It is designed for use in scripts or Git internals, not direct end-user interaction.

The input must follow a precise canonical format:
object <SHA-1 of tagged object>
type <object type, e.g., commit>
tag <tag name>
tagger <name> <<email>> <Unix timestamp> <timezone offset>

<tag message>

Upon success, it outputs the SHA-1 hash of the created tag object followed by a newline and the binary object data. This enables programmatic creation of lightweight or annotated tags without higher-level commands like git tag.

Commonly used in combination with other plumbing commands to build Git repositories from scratch or manipulate objects directly. It enforces strict input validation, exiting with code 1 on parse errors or invalid data.

CAVEATS

Strict input format required; no options or arguments supported. Exits with code 1 on any error. Not for interactive use.

INPUT FORMAT EXAMPLE

object 9d5ba3fb713ff9ea2b0af9a8ab3d5d1a2c8f4f3e
type commit
tag v1.0
tagger John Doe <john@example.com> 1699123456 +0000

Release version 1.0

HISTORY

Introduced in early Git versions (pre-1.0) as part of the core plumbing layer to support Git's object database model. Remains unchanged, reflecting Git's stable low-level API design.

SEE ALSO

Copied to clipboard