🔧 Git Internals Inspection Scripts
🛠️ Powerful Tools for Git Exploration
A collection of shell scripts to inspect, analyze, and understand Git's internals
📋 Available Scripts
| Script | Purpose | Difficulty |
|---|---|---|
| inspect-index.sh | Deep dive into the staging area | ⭐ Beginner |
| inspect-objects.sh | Explore the object database | ⭐ Beginner |
| inspect-refs.sh | Examine branches, tags, and HEAD | ⭐ Beginner |
| git-internals-dump.sh | Complete repository snapshot | ⭐⭐ Intermediate |
| watch-git-changes.sh | Real-time .git monitoring | ⭐⭐ Intermediate |
| create-commit-manually.sh | Build commit with plumbing only | ⭐⭐⭐ Advanced |
| compare-branches.sh | Compare branch internals | ⭐⭐ Intermediate |
| find-blob.sh | Track blob through history | ⭐⭐⭐ Advanced |
🚀 Quick Start
bash
# Make all scripts executable
chmod +x *.sh
# Run any script from a Git repository
./inspect-index.sh
# Or specify a repo path
./inspect-objects.sh /path/to/repo📝 Script Descriptions
inspect-index.sh
Purpose: Deep inspection of the Git staging area (index)
bash
./inspect-index.sh [repo-path]What it shows:
- All staged files with modes and SHAs
- File count and total size
- Modified, deleted, and untracked files
- Stage numbers (for merge conflicts)
inspect-objects.sh
Purpose: Explore all objects in the database
bash
./inspect-objects.sh [repo-path]What it shows:
- Count of blobs, trees, commits, tags
- Loose vs packed objects
- Object sizes
- Sample content from each type
inspect-refs.sh
Purpose: Complete view of all Git references
bash
./inspect-refs.sh [repo-path]What it shows:
- All branches (local and remote)
- Tags (annotated and lightweight)
- HEAD status
- Reflog entries
git-internals-dump.sh
Purpose: Full repository snapshot for analysis
bash
./git-internals-dump.sh [repo-path] [output-dir]What it creates:
- Complete object listing
- Index dump
- Refs snapshot
- Config backup
- Hooks inventory
watch-git-changes.sh
Purpose: Monitor .git directory in real-time
bash
./watch-git-changes.sh [repo-path]What it shows:
- File creation/modification events
- Object additions
- Ref updates
- Index changes
create-commit-manually.sh
Purpose: Create a commit using only plumbing commands
bash
./create-commit-manually.sh [repo-path]What it demonstrates:
- Blob creation with
hash-object - Index manipulation with
update-index - Tree creation with
write-tree - Commit creation with
commit-tree - Branch update with
update-ref
compare-branches.sh
Purpose: Compare two branches at the object level
bash
./compare-branches.sh branch1 branch2 [repo-path]What it shows:
- Commit differences
- Tree divergence point
- Unique blobs per branch
- Common ancestry
find-blob.sh
Purpose: Track a blob through commit history
bash
./find-blob.sh <blob-sha> [repo-path]What it shows:
- Which commits contain the blob
- File names associated with the blob
- When blob was introduced/removed
💡 Tips
- Run from repo root - Most scripts auto-detect
.gitif run from repo root - Pipe to less - For large repos:
./inspect-objects.sh | less - Export to file - Save output:
./git-internals-dump.sh > dump.txt - Combine scripts - Chain them for deeper analysis
⚠️ Notes
- Scripts are read-only - they won't modify your repository
- Some scripts may be slow on large repos with many objects
- Requires standard Unix tools:
find,awk,sed,sort - Works on Linux, macOS, and WSL
📚 Learn More
These scripts are companions to the Git Internals course: