Skip to main content
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

CommandDescription
listShow installed hooks
install <name>Install a hook from template
remove <name>Remove a hook
run <name>Test a hook manually

Available Hooks

HookTriggered
pre-commitBefore commit is created
post-commitAfter commit is created
pre-mergeBefore merge starts
post-mergeAfter 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

CommandDescription
add <url> <path>Add a submodule
initInitialize submodules
updateUpdate submodules to recorded commits
statusShow 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"
For more details, see Submodules.

Worktrees

Work on multiple branches simultaneously with multiple working directories.
wit worktree <command> [options]

Commands

CommandDescription
add <path> <branch>Create new worktree
listList all worktrees
remove <path>Remove a worktree
pruneRemove 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
For more details, see Worktrees.

Reflog

View reference history for recovery.
wit reflog [ref] [options]

Options

OptionDescription
expirePrune 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.
wit gc [options]

Options

OptionDescription
--aggressiveMore thorough optimization (slower)
--prune=<date>Prune objects older than date
--prune=nowPrune 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

CommandDescription
set <path>Set the current scope
use <preset>Use a predefined scope
clearClear 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
For more details, see Monorepo Scopes.

Plumbing Commands

Low-level commands for scripting and advanced use.

hash-object

wit hash-object <file>
Calculate the hash of a file.

cat-file

wit cat-file <hash>
Display contents of an object.

ls-tree

wit ls-tree <tree-hash>
List contents of a tree object.

ls-files

wit ls-files
List files in the index.

rev-parse

wit rev-parse <rev>
Parse a revision to its hash.

for-each-ref

wit for-each-ref
Iterate over references.

update-ref

wit update-ref <ref> <hash>
Update a reference.

symbolic-ref

wit symbolic-ref <name>
Read or set a symbolic reference.

show-ref

wit show-ref
List references.