Audit a Release or Tag in a Worktree
Inspect a specific tagged release without disturbing your current working directory.
When to use
You need to investigate a bug reported in a specific release, review what shipped in a particular version, or compare current code against a tagged release.
Pre-flight
- Know the tag name or release version you need to audit (e.g.,
v2.0.0,release-2024-01). - Ensure tags are fetched from the remote:
git fetch --tags.
Steps
-
Fetch the latest tags from the remote.
git fetch --tags -
Create a worktree in detached HEAD state pointing at the tag.
git worktree add --detach ../v2-audit v2.0.0The
--detachflag creates the worktree without checking out a branch, perfect for read-only inspection. -
Navigate to the audit directory and investigate.
cd ../v2-audit # Check the exact commit git log -1 # Search for specific code grep -r "buggyFunction" src/ # Run the old version if needed npm ci && npm start -
When finished, remove the audit worktree.
cd ../your-main-repo git worktree remove ../v2-audit
Verification
git worktree listin the audit directory shows(detached HEAD).git describe --tagsconfirms you are at the expected tag.
Why use --detach?
Tags point to specific commits, not branches. Using --detach:
- Avoids creating an unnecessary local branch.
- Makes it clear this is a read-only inspection.
- Prevents accidental commits to a release point.
Alternative: Audit a specific commit
Works the same way with commit hashes:
git worktree add --detach ../commit-audit abc1234
Follow-up
- Document any issues found during the audit.
- If a bug is confirmed, create a fix on the appropriate branch.