Skip to main content
Documentation

Diff & Compare Commands

View differences between commits, branches, working directory, and staged changes. Understand exactly what changed and when.

dits diff

Show changes between the working directory and the index (staging area), or between commits.

Synopsis

dits diff [OPTIONS] [<commit>] [--] [<path>...]
dits diff [OPTIONS] <commit> <commit> [--] [<path>...]

Options

--staged, --cached    Compare staged changes to last commit
--stat               Show diffstat summary
--name-only          Only show changed file names
--name-status        Show name and status (A/M/D)
-p, --patch          Show full patch (default)
--no-color           Disable colored output
-w, --ignore-space   Ignore whitespace changes
--word-diff          Show word-level differences
--binary             Show binary file differences
--chunk-diff         Show chunk-level differences (Dits-specific)

Common Use Cases

View Unstaged Changes

# See what you've changed but not staged
$ dits diff
diff --dits a/src/main.ts b/src/main.ts
--- a/src/main.ts
+++ b/src/main.ts
@@ -10,7 +10,8 @@
 function main() {
-  console.log("Hello");
+  console.log("Hello, World!");
+  console.log("Welcome to Dits");
 }

View Staged Changes

# See what will be committed
$ dits diff --staged

# Same as
$ dits diff --cached

Compare Commits

# Compare two commits
$ dits diff abc1234 def5678

# Compare with parent commit
$ dits diff HEAD~1 HEAD

# Compare branch with main
$ dits diff main feature/new-ui

Diff Specific Files

# Diff a specific file
$ dits diff -- src/config.ts

# Diff multiple files
$ dits diff -- src/*.ts

# Diff directory
$ dits diff -- src/components/

dits diff --stat

Get a summary of changes without the full diff:

$ dits diff --stat HEAD~5
 src/index.ts         |  23 +++++++++++----
 src/utils/helpers.ts |   8 ++---
 package.json         |   3 +-
 README.md            | 156 +++++++++++++++++++++++++++++++++++++
 4 files changed, 175 insertions(+), 15 deletions(-)

dits diff --chunk-diff

Dits-specific feature to see differences at the chunk level. Useful for understanding how binary files changed:

$ dits diff --chunk-diff video.mov
Chunk changes for video.mov:
  Total chunks: 1,234 -> 1,256
  New chunks: 45
  Removed chunks: 23
  Unchanged: 1,189 (96.4%)
  
  Affected regions:
    0:00:00 - 0:02:30  (unchanged)
    0:02:30 - 0:05:45  (modified, 22 new chunks)
    0:05:45 - 0:15:00  (unchanged)
    0:15:00 - 0:18:30  (modified, 23 new chunks)

dits show

Show details of a specific commit, including the diff:

# Show most recent commit
$ dits show

# Show specific commit
$ dits show abc1234

# Show only the files changed
$ dits show --name-only abc1234

# Show a file at a specific commit
$ dits show abc1234:src/main.ts

dits difftool

Open differences in an external diff viewer:

# Configure diff tool
$ dits config --global diff.tool vscode
$ dits config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'

# Use difftool
$ dits difftool HEAD~1 HEAD

# Diff specific file with tool
$ dits difftool -- src/main.ts

Useful Aliases

# Add these to your config
dits config --global alias.d 'diff'
dits config --global alias.ds 'diff --staged'
dits config --global alias.dstat 'diff --stat'
dits config --global alias.last 'diff HEAD~1 HEAD'

# Usage
$ dits ds        # Staged changes
$ dits dstat     # Change summary  
$ dits last      # What changed in last commit

Related Commands