Learning center

Which commit was this Go binary built from, and was the tree clean?

Run go version -m on the binary and read the vcs.revision, vcs.time and vcs.modified lines. A value of vcs.modified=false means the build tree matched that commit. A value of vcs.modified=true means it did not, and an untracked file is enough to set it. If the lines are missing, the build saw no repository or stamping was turned off, and the binary cannot tell you which commit it came from.

What the go command records#

By default the go command stamps version control information "if the main package, the main module containing it, and the current directory are all in the same repository". -buildvcs=false always omits it. Build flags The runtime/debug package defines vcs.revision as "the revision identifier for the current commit or checkout" and vcs.modified as "true or false indicating whether the source tree had local modifications". BuildSetting go version -m prints these settings from the binary. go version

One commit, six builds#

This fixture builds one commit six ways in the golang:1.25 image (go1.25.14):

## 1. clean checkout
	build	vcs=git
	build	vcs.revision=724742f62fc9f47c913f9b59370f93226e11bbba
	build	vcs.time=2026-11-30T10:00:00Z
	build	vcs.modified=false
## 2. untracked file in the tree
	build	vcs=git
	build	vcs.revision=724742f62fc9f47c913f9b59370f93226e11bbba
	build	vcs.time=2026-11-30T10:00:00Z
	build	vcs.modified=true
## 3. edited tracked file, not committed
[…same four lines as build 2…]
## 4. -buildvcs=false
(no vcs lines)
## 5. source copied without .git
(no vcs lines)
## 6. .git owned by another user
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
exit 1

Builds 2 and 3 carry the same revision and the same true, although only build 3 compiled code that differs from the commit. Build 2's tree held a stray notes.txt that the compiler never read. The flag tells you that the tree differed, not how. A second run showed that a file listed in .gitignore leaves the flag false, and that -ldflags values appear on their own build line.

Builds 4 and 5 both succeed and both leave no trace. A CI step that copies sources into a build container without .git, or a Dockerfile COPY with .git excluded, produces build 5 silently.

Build 6 fails loudly. Git refuses a repository owned by another user, which happens when a container builds a checkout made by the runner's user. Adding -buildvcs=false, as the message suggests, turns it into build 4. Listing the directory in Git's safe.directory setting keeps the stamp. safe.directory

Decide what the binary tells you#

go version -m showsIt establishesRead next
vcs.modified=falseThe tracked source matched vcs.revision, and no untracked file outside .gitignore was presentThe Go version on the first line and the build -ldflags line
vcs.modified=trueThe tree differed from vcs.revision in some fileThe build log, or git status --porcelain run in the build step
No vcs linesNothing about the commitThe build job's checkout and copy steps

A clean stamp describes the main module's source. Dependencies appear on separate dep lines with their own versions, and nothing in the stamp shows that tests ran on this binary.

Worked example#

This example is fictional. Dara compares a production binary with the release tag. The revision matches, but vcs.modified=true. The release job's log shows a step that writes version.txt into the checkout before go build, and the file is not in .gitignore. She searches the code for a //go:embed that reads it, because an embedded file would put the difference into the binary, and finds none. Dara records the revision with that explanation and adds version.txt to .gitignore, so the next release stamps false and needs no explanation.

For the toolchain line, read standard library vulnerabilities in Go binaries. For cached test results, read go test cached result.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading