Git Internals and Plumbing

Low-level Git objects, refs, trees, index, commit creation, and packfile plumbing for advanced users and debugging.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Objects and Content Plumbing
Write blob object
git hash-object -w path/to/file

# Store file content as a blob and print its object ID.

Write blob from stdin
printf "hello
" | git hash-object -w --stdin

# Write blob content from standard input.

Object type
git cat-file -t <object_sha>

# Show object type.

Object size
git cat-file -s <object_sha>

# Show object size in bytes.

Pretty-print object
git cat-file -p <object_sha>

# Display object content.

Count loose objects
git count-objects -vH

# Show object counts and disk usage.

## Trees and Index Plumbing
List tracked files
git ls-files

# Print index entries.

List staged index entries
git ls-files --stage

# Include mode, object ID, and stage number.

Mark file assume-unchanged
git update-index --assume-unchanged path/to/file

# Hint that Git should skip stat checks for a path.

Mark skip-worktree
git update-index --skip-worktree path/to/file

# Tell Git to avoid touching a path in sparse-like workflows.

Write current index to tree
git write-tree

# Create a tree object from the index.

Read tree into index
git read-tree HEAD

# Populate index from a tree-ish.

## Refs and Symbolic Refs
List refs
git show-ref

# List local refs and object IDs.

Format refs
git for-each-ref --format='%(refname:short) %(objectname:short)' refs/heads

# Script-friendly ref iteration.

Update ref atomically
git update-ref refs/heads/tmp <commit_sha>

# Create or move a ref directly.

Read symbolic ref
git symbolic-ref HEAD

# Print the symbolic target of HEAD.

Pack refs
git pack-refs --all --prune

# Store refs efficiently in packed-refs.

## Commit and History Plumbing
Create commit from tree
echo "commit message" | git commit-tree <tree_sha> -p <parent_sha>

# Create a commit object directly.

List commit IDs
git rev-list HEAD

# Enumerate commits reachable from HEAD.

List commits and objects
git rev-list --objects HEAD

# Enumerate reachable objects.

Diff tree objects
git diff-tree --stat HEAD~1 HEAD

# Compare tree objects without porcelain diff.

Verify commit revision
git rev-parse --verify HEAD^{commit}

# Ensure a revision resolves to a commit.

## Transfer and Packfile Plumbing
Index pack file
git index-pack pack-123.pack

# Create index for an existing pack.

Inspect pack contents
git verify-pack -v .git/objects/pack/pack-123.idx

# Examine packed object storage.

Create pack from stdin list
printf "%s
" <object_sha> | git pack-objects out/pack

# Create a pack from listed objects.

Unpack objects from stream
git unpack-objects < pack-123.pack

# Inflate objects from a pack stream.