Analyze which commits in a range can be safely reordered without conflicts.
Given a range of commits, git-commit-dag uses patch commutation to build a dependency DAG — showing which commits must come before which others, and which are independent.
git commit-dag <base>..<last> [--svg] [--context N] [--show-files] [--whole-file]
git commit-dag <base> <last> [--svg] [--context N] [--show-files] [--whole-file]
git commit-dag --explain <commit1> <commit2> [--context N] [--whole-file]
The range follows standard git conventions: base is excluded, last is included (same as git log base..last).
| Option | Description |
|---|---|
--explain |
Show conflicting hunks between two specific commits |
--svg |
Output as SVG |
--context N |
Expand hunks by N context lines (default 0; git apply uses 3) |
--show-files |
Show which files cause each dependency |
--whole-file |
Treat any two commits touching the same file as dependent |
$ git commit-dag HEAD~4 HEAD
○ d11afa9 A: modify line1 of file1
│ ○ cc006b8 C: modify file2
│ │
○ │ 03487f3 B: modify line1 of file1 again
├─┘
○ 0a7d408 D: modify both files
411e44d E: update README (independent)
Use --explain to see why two commits depend on each other:
$ git commit-dag --explain abc1234 def5678
abc1234 Fix login validation
def5678 Add rate limiting
auth.rs:
[abc1234] @@ -42,1 +42,1 @@
-old_check()
+new_check()
[def5678] @@ -43,0 +43,2 @@
+rate_limit()
+log_attempt()
Use --svg for graphical output:
git commit-dag HEAD~10 HEAD --svg > deps.svg
cargo build --release
cp target/release/git-commit-dag ~/.local/bin/
- Textual analysis only — semantically dependent commits that touch different lines won't be detected.
- Binary files, renames, and submodules are not analyzed.
- Uses zero context lines by default, which is slightly more permissive than
git apply. Use--context 3to match git's default.
BSD-3-Clause. Patch commutation algorithm vendored from git-absorb.