Use git show REF:path to read a committed file from another branch without switching branches or replacing the index. Restoring a file into the working tree is a different operation. Choose based on whether you want inspection, a separate copy or an actual replacement.
Reproduce the boundary in a disposable fixture
Use object inspection when you need the content, and restore only when replacement is intended.
Use a new empty temporary directory for this fixture. The example creates only local test data. Commands marked with example.invalid do not identify a real service.
git init -q demo
cd demo
git config user.name Fixture
git config user.email fixture@example.invalid
printf 'base
' > config.txt
git add config.txt
git commit -qm base
git branch baseline
printf 'local edit
' > config.txt
before=$(git hash-object config.txt)
git show baseline:config.txt > ../baseline-copy.txt
test "$(cat ../baseline-copy.txt)" = base
test "$before" = "$(git hash-object config.txt)"
git diff --cached --exit-code
git status --shortObserved result
M config.txtWhat the result means
The baseline copy contains committed content from the named ref, while config.txt keeps its uncommitted local edit. The index remains unchanged. The path after the colon is a repository object path, not a destination filename. The output redirection determines where the copy goes; it can overwrite that output file even though Git itself is only inspecting an object.
Choose the correction for your workflow
Confirm the source ref and repository-relative path. Inspect with git show REF:path before saving to a new, deliberate destination. For a filename containing spaces, quote the complete REF:path argument. For a nested working directory, use a repository-root-relative object path so the intended blob is unambiguous. If the source exists only on a remote, the relevant commit must first be available locally through the project authorized fetch workflow. Do not switch branches merely to read one committed blob when current edits must stay intact.
Limits and the next check
The fixture uses a small text file and a separate output path in a disposable directory. git show output is not a full checkout operation with every working-tree filter, symlink or file-mode behavior applied. It also cannot recover edits that were never committed into the referenced object. If you intentionally want to replace your working file or index, use a separately reviewed restore operation and inspect the resulting diff; the existing staged-versus-HEAD guide covers that boundary.
Related: Compare the related workflow boundary.
This isolated example was executed on macOS on November 10, 2026 (KST). Available tools: node v26.5.0, git git version 2.39.3 (Apple Git-145), npm 11.17.0, jq jq-1.7.1-apple. Shell fixtures use Bash and repository-path identity uses Python 3. This checks the illustrated contract, not your project, host service or every tool version.