Skip to main content
These are the commands you’ll use most often for day-to-day version control.

init

Create a new wit repository.
wit init [path]

Arguments

ArgumentDescription
pathOptional. Directory to initialize. Defaults to current directory.

Examples

# Initialize in current directory
wit init

# Initialize in a new directory
wit init my-project

add

Stage files for the next commit.
wit add <files...>

Arguments

ArgumentDescription
filesFiles or directories to stage. Use . for all files.

Examples

# Stage a single file
wit add README.md

# Stage multiple files
wit add src/index.ts src/utils.ts

# Stage all files
wit add .

# Stage all TypeScript files
wit add "*.ts"

commit

Create a new commit with the staged changes.
wit commit -m <message> [options]

Options

OptionDescription
-m <message>Commit message (required)
-a, --allStage all tracked files before committing

Examples

# Commit staged changes
wit commit -m "Add user authentication"

# Stage all tracked files and commit
wit commit -a -m "Update configuration"
Use wit wip for quick work-in-progress commits with auto-generated messages.

status

Show the working tree status.
wit status

Output Explanation

  • Staged changes: Files ready to be committed
  • Unstaged changes: Modified files not yet staged
  • Untracked files: New files not tracked by wit

Example Output

On branch main

Staged changes:
  modified: src/index.ts
  new file: src/utils.ts

Unstaged changes:
  modified: README.md

Untracked files:
  notes.txt

log

Show commit history.
wit log [options]

Options

OptionDescription
--onelineCompact one-line format
-n <number>Limit to last N commits

Examples

# Full log
wit log

# Compact format
wit log --oneline

# Last 5 commits
wit log -n 5

Example Output

commit a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Author: Alice <alice@example.com>
Date:   2024-01-15 10:30:00

    Add user authentication

commit q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2
Author: Bob <bob@example.com>
Date:   2024-01-14 15:45:00

    Initial commit

diff

Show changes between commits, or between the working tree and a commit.
wit diff [options] [path]

Options

OptionDescription
--stagedShow staged changes
--cachedAlias for --staged

Examples

# Show unstaged changes
wit diff

# Show staged changes
wit diff --staged

# Show changes in specific file
wit diff src/index.ts

Example Output

diff --git a/src/index.ts b/src/index.ts
--- a/src/index.ts
+++ b/src/index.ts
@@ -10,6 +10,7 @@ export function main() {
   console.log("Starting application");
+  initializeDatabase();
   startServer();
 }

Workflow Example

Here’s a typical workflow using these commands:
# 1. Check current status
wit status

# 2. Make some changes to files...

# 3. Review your changes
wit diff

# 4. Stage specific files
wit add src/feature.ts

# 5. Review what's staged
wit diff --staged

# 6. Commit
wit commit -m "Add new feature"

# 7. View history
wit log --oneline