A version label is useful only when everyone can resolve it to the same release inputs. If a tag moves after a package is published, two consumers can use the same version name while receiving artifacts built from different commits. Give each release an explicit commit identity and treat its published label as part of the release contract.
This guide covers local tag creation, narrow publication, and verification. The commands use a synthetic version and Git 2.45.2 syntax supported by PowerShell and Bash. They do not publish a package or establish that a build is trustworthy by themselves.
Identify what the release label must connect
Before tagging, collect the candidate commit, version, build record, artifact identifiers, and compatibility decision. Those are distinct pieces of evidence. A commit identifies source history; an artifact digest identifies distributed bytes; a release version communicates a public compatibility promise.
Inspect the intended checkout without assuming that the branch name is enough:
git status --short --branch
git rev-parse HEAD
git log -1 --format=fuller
A clean working tree helps avoid confusion about uncommitted inputs, but it does not prove that an artifact was built from this commit. The build record should independently name the source commit and artifact identity. Resolve that relationship before adding the release label.
For a synthetic v1.4.0 candidate, require that the recorded version agrees with the intended compatibility change. The public API versioning guide explains that decision. Do not choose a version merely because it is the next number in a list of existing tags.
Choose annotated metadata deliberately
The Git tag documentation distinguishes lightweight references from annotated tag objects. An annotated object includes a tagger, date, message, and optional signature. That metadata gives a release label a reviewable context; it does not replace testing or artifact verification.
After confirming that HEAD is the intended candidate, create the synthetic annotated tag:
git tag -a v1.4.0 HEAD -m "Release 1.4.0"
git show --no-patch v1.4.0
git rev-parse 'v1.4.0^{commit}'
Compare the peeled commit identity with the recorded candidate. Annotated tag objects and commits have different object identities, so comparing the tag object's hash directly with the commit hash is the wrong check.
If signing is part of your release policy, create and verify the tag through the configured signing system. A successful cryptographic verification establishes that the signature matches the object under the verifier's trust configuration. It does not establish that the signer reviewed the code, that the account was uncompromised, or that the published artifact corresponds to the tag.
Publish only the intended reference
Confirm which remote is the approved release destination through your normal repository configuration process. Do not copy a remote name from another project. After reviewing the proposed update, publish one explicit tag reference:
git push --dry-run origin refs/tags/v1.4.0:refs/tags/v1.4.0
git push origin refs/tags/v1.4.0:refs/tags/v1.4.0
The Git push manual documents explicit refspecs and the dry-run option. Using a narrow refspec makes the proposed remote change easier to review than a command that sends every local tag.
A dry run is not a reservation. Remote policy, network state, or another publisher can change before the actual update. Inspect the real command's result. If a tag already exists with a different identity, stop and investigate ownership instead of forcing the update.
Release automation may react as soon as the remote tag appears. Put required tests and approvals before the publication step, or design the workflow so that an unverified tag cannot produce a public artifact. The repository's branch permissions do not necessarily describe its tag protections.
Verify the remote and the distributed result separately
Read back the remote reference after publication:
git ls-remote --tags origin 'refs/tags/v1.4.0*'
For an annotated tag, compare the exact tag reference and its peeled commit with the expected local identities. The wildcard can also return similarly prefixed names, so inspect the full reference rather than accepting the first line. Authentication success and command exit status are insufficient if the wrong reference was queried.
Next, verify the artifact independently. Compare its published digest, version metadata, and build record with the release manifest. Download availability does not prove that the file is the verified build. A correctly published tag can still be paired with a stale package or a rebuild using different dependencies.
The guide to checksums, signatures, and provenance explains these separate claims. Make the release record usable without relying on a mutable web page title or the current position of a branch.
Recover from mistakes without changing the meaning of a release
If a local tag is wrong and has never been shared, correct it before publication using the team's normal local workflow. If it has already triggered distribution or consumers have fetched it, treat the problem as a release incident.
Record the incorrect relationship, stop affected automation when necessary, and choose a new corrected version or label. Explain which artifacts are affected and how consumers can identify them. Deleting or moving the old tag does not remove copies already fetched or packages already cached.
Restrict who can create and change release tags, retain the manifest, and test the automation's behavior when a duplicate label appears. A stable tag is most useful when it connects a documented compatibility decision to one source commit and one verified set of artifacts for the lifetime of that release.
Was this guide useful?
Your rating helps us prioritize clearer, more practical technical content.
Review diffs, run checks, and prepare the release in Arezgit.
Keep Git review, security scanning, API checks, database inspection, and release preparation together in one local desktop application.
Explore Arezgit