These commands provide powerful capabilities for advanced workflows.
For stacked diffs, see Stacked Diffs.
For history rewriting (cherry-pick, rebase, revert), see History Rewriting.
For remote operations, see Remotes.
For stash, see Stash.
For tags, see Tags.
For debugging (bisect, show, clean), see Debugging.
Hooks
Customize behavior at key points in the version control workflow.
wit hooks <command> [hook-name]
Commands
| Command | Description |
|---|
list | Show installed hooks |
install <name> | Install a hook from template |
remove <name> | Remove a hook |
run <name> | Test a hook manually |
Available Hooks
| Hook | Triggered |
|---|
pre-commit | Before commit is created |
post-commit | After commit is created |
pre-merge | Before merge starts |
post-merge | After merge completes |
Examples
# List installed hooks
wit hooks
# Install pre-commit hook
wit hooks install pre-commit
# Test the hook
wit hooks run pre-commit
# Remove a hook
wit hooks remove pre-commit
Hook Location
Hooks are stored in .wit/hooks/. Edit them to customize behavior:
# Example pre-commit hook
#!/bin/bash
npm run lint
npm run test
For more details, see Hooks.
Submodules
Manage nested repositories within your project.
wit submodule <command> [options]
Commands
| Command | Description |
|---|
add <url> <path> | Add a submodule |
init | Initialize submodules |
update | Update submodules to recorded commits |
status | Show submodule status |
foreach <cmd> | Run command in each submodule |
Examples
# Add a submodule
wit submodule add https://github.com/lib/utils.git vendor/utils
# Initialize after cloning
wit submodule init
# Update to latest recorded commits
wit submodule update
# Check status
wit submodule status
# Run a command in all submodules
wit submodule foreach "npm install"
Worktrees
Work on multiple branches simultaneously with multiple working directories.
wit worktree <command> [options]
Commands
| Command | Description |
|---|
add <path> <branch> | Create new worktree |
list | List all worktrees |
remove <path> | Remove a worktree |
prune | Remove stale worktree entries |
Examples
# Create worktree for feature development
wit worktree add ../feature-worktree feature-branch
# List all worktrees
wit worktree list
# Remove when done
wit worktree remove ../feature-worktree
# Clean up stale entries
wit worktree prune
Use Case
# You're working on a feature but need to hotfix main
wit worktree add ../hotfix main
# Now you have two directories:
# - /project (your feature work, untouched)
# - /hotfix (clean main branch)
cd ../hotfix
# Fix the bug...
wit commit -a -m "Hotfix: critical bug"
# Go back to feature work
cd ../project
# Your feature branch is exactly as you left it!
# Clean up
wit worktree remove ../hotfix
Reflog
View reference history for recovery.
wit reflog [ref] [options]
Options
| Option | Description |
|---|
expire | Prune old reflog entries |
Examples
# Show HEAD reflog
wit reflog
# Show reflog for specific branch
wit reflog main
# Prune old entries
wit reflog expire
Example Output
HEAD@{0}: commit: Add authentication
HEAD@{1}: switch: moving from feature to main
HEAD@{2}: commit: Fix login bug
HEAD@{3}: merge: feature-auth
HEAD@{4}: commit: Initial setup
The reflog is what powers wit undo. Every operation is recorded and can be reversed.
Garbage Collection
Clean up and optimize the repository.
Options
| Option | Description |
|---|
--aggressive | More thorough optimization (slower) |
--prune=<date> | Prune objects older than date |
--prune=now | Prune all unreachable objects immediately |
Examples
# Standard garbage collection
wit gc
# Aggressive optimization
wit gc --aggressive
# Prune immediately
wit gc --prune=now
When to Run
- After deleting many branches
- After undoing many operations
- When repository feels slow
- Before backing up (reduces size)
Monorepo Scopes
Limit operations to specific paths in a monorepo.
wit scope <command> [path]
Commands
| Command | Description |
|---|
set <path> | Set the current scope |
use <preset> | Use a predefined scope |
clear | Clear scope (full repository) |
| (none) | Show current scope |
Examples
# Check current scope
wit scope
# Limit to src directory
wit scope set src/
# Use preset
wit scope use frontend
# Clear scope
wit scope clear
Effect on Commands
When a scope is set:
wit scope set packages/frontend/
wit status # Shows only frontend files
wit add . # Stages only frontend files
wit log # Shows commits affecting frontend
wit diff # Shows changes in frontend only
Plumbing Commands
Low-level commands for scripting and advanced use.
hash-object
Calculate the hash of a file.
cat-file
Display contents of an object.
ls-tree
List contents of a tree object.
ls-files
List files in the index.
rev-parse
Parse a revision to its hash.
for-each-ref
Iterate over references.
update-ref
wit update-ref <ref> <hash>
Update a reference.
symbolic-ref
Read or set a symbolic reference.
show-ref
List references.