> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wit.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic Workflow

> Essential commands for daily version control

These are the commands you'll use most often for day-to-day version control.

## init

Create a new wit repository.

```bash theme={null}
wit init [path]
```

### Arguments

| Argument | Description                                                       |
| -------- | ----------------------------------------------------------------- |
| `path`   | Optional. Directory to initialize. Defaults to current directory. |

### Examples

```bash theme={null}
# Initialize in current directory
wit init

# Initialize in a new directory
wit init my-project
```

***

## add

Stage files for the next commit.

```bash theme={null}
wit add <files...>
```

### Arguments

| Argument | Description                                           |
| -------- | ----------------------------------------------------- |
| `files`  | Files or directories to stage. Use `.` for all files. |

### Examples

```bash theme={null}
# 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.

```bash theme={null}
wit commit -m <message> [options]
```

### Options

| Option         | Description                               |
| -------------- | ----------------------------------------- |
| `-m <message>` | Commit message (required)                 |
| `-a`, `--all`  | Stage all tracked files before committing |

### Examples

```bash theme={null}
# Commit staged changes
wit commit -m "Add user authentication"

# Stage all tracked files and commit
wit commit -a -m "Update configuration"
```

<Tip>
  Use `wit wip` for quick work-in-progress commits with auto-generated messages.
</Tip>

***

## status

Show the working tree status.

```bash theme={null}
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.

```bash theme={null}
wit log [options]
```

### Options

| Option        | Description             |
| ------------- | ----------------------- |
| `--oneline`   | Compact one-line format |
| `-n <number>` | Limit to last N commits |

### Examples

```bash theme={null}
# 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.

```bash theme={null}
wit diff [options] [path]
```

### Options

| Option     | Description          |
| ---------- | -------------------- |
| `--staged` | Show staged changes  |
| `--cached` | Alias for `--staged` |

### Examples

```bash theme={null}
# Show unstaged changes
wit diff

# Show staged changes
wit diff --staged

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

### Example Output

```diff theme={null}
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:

```bash theme={null}
# 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
```
