Progress:
TIER 3 · MODULE 42· Expert

git unpack-file

Plumbing helpful in mergetool wrappers.

🎯 What & why

git unpack-file writes the contents of a single blob object to a temp file and prints the path. Plumbing glue used inside mergetool wrappers and diff drivers.

🧠 Mental model

Takes a blob SHA, dumps its raw bytes to a file named .merge_file_XXXXXX in the worktree, echoes the filename. That's the entire job - you clean up after.

🛠️ Synopsis

git unpack-file <blob>

🎚️ Switches & options

FlagWhat it does
<blob>Required positional: the SHA of a blob object to materialize.

💡 Use cases

🧪 Examples

Dump a blob to a temp file
git unpack-file 4b825dc642cb6eb9a060e54bf8d69288fbee4904
Use in a merge driver
BASE=$(git unpack-file $1); LOCAL=$(git unpack-file $2); REMOTE=$(git unpack-file $3)
Inspect then clean up
f=$(git unpack-file HEAD:README.md); less "$f"; rm "$f"
Compare two historical versions
diff $(git unpack-file HEAD:a.c) $(git unpack-file HEAD~5:a.c)

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

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