Progress:
TIER 3 · MODULE 29· Expert

git get-tar-commit-id

Recover provenance from a tarball produced by git archive.

🎯 What & why

git get-tar-commit-id reads a tar archive on stdin and prints the commit SHA that produced it. Useful for verifying provenance of release tarballs made with git archive.

🧠 Mental model

git archive embeds the source commit ID in a pax extended header inside the tar. This command just digs that field out, no repo needed.

🛠️ Synopsis

git get-tar-commit-id < <tarball.tar>
git archive --format=tar HEAD | git get-tar-commit-id

🎚️ Switches & options

FlagWhat it does
(none)Reads tar from stdin; writes 40-char SHA + newline to stdout
(no flags)This command takes no flags or arguments
exit 1Returned if the tar has no embedded commit ID
works offlineNo repository required to run

💡 Use cases

🧪 Examples

Read SHA from a tarball
git get-tar-commit-id < release-1.2.tar
Pipe straight from archive
git archive --format=tar HEAD | git get-tar-commit-id
Verify against a tag
git get-tar-commit-id < dist.tar | grep -q $(git rev-parse v1.2^{})
From a gzipped tarball
gunzip -c release.tar.gz | git get-tar-commit-id

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.