Rebase stacked worktree branches in dependency order.
Works with any git worktrees — no special setup required. Can also be used as an external subcommand for worktrunk via wt sync.
wt sync detects the branch dependency tree from git's commit graph using pairwise merge-base analysis, then rebases each branch onto its parent in topological order.
All rebases use --onto with a stored fork-point, so parent branches that have been rewritten (rebased, amended, or force-pushed) are handled correctly — no duplicate commits or spurious conflicts.
Two files are stored in .git/wt/ (shared across all worktrees):
stack— the dependency tree in git-machete compatible format, used for parent tracking and integration detection.stack-forkpoints— each branch's parent SHA at last sync, used as the--ontobase for the next rebase.
Both files are auto-created and updated on every sync.
cargo install worktrunk-syncThe binary is named wt-sync and can be run directly. If worktrunk is installed, it also works as wt sync via external subcommand dispatch.
wt-sync # sync the current stack (default)
wt-sync --all # sync all stacks
wt-sync -nv # preview the plan with git commands
# Or via worktrunk:
wt sync
wt sync --allwt sync --fetch --push --pruneThis fetches from the remote, rebases branches in the current stack, pushes the rebased branches, and removes any worktrees whose branches have been merged.
| Flag | Short | Description |
|---|---|---|
--stack |
-s |
Sync only the current stack (default) |
--all |
-a |
Sync all stacks |
--fetch |
-f |
Fetch from remote before syncing |
--push |
-p |
Push rebased branches after syncing |
--prune |
-P |
Remove integrated worktrees after syncing |
--force |
-F |
Force removal of dirty integrated worktrees (with --prune) |
--verbose |
-v |
Show git commands that would be executed |
--dry-run |
-n |
Preview the sync plan without executing |
$ wt-sync -nv
Dependency tree:
main
├── feature-a
│ └── feature-b
└── feature-c
Planned operations:
rebase feature-a onto main
$ git rebase --onto main abc1234 feature-a
rebase feature-b onto feature-a
$ git rebase --onto feature-a def5678 feature-b
rebase feature-c onto main
$ git rebase --onto main abc1234 feature-c
- Zero configuration — dependencies are inferred from git history
- Fork-point tracking — stores the parent SHA at each sync so
--ontorebases work correctly even after the parent is rewritten - Integrated branch detection — branches merged into their parent (or into the default branch) are detected; their children are reparented automatically
- Conflict handling — stops on first conflict with instructions to resolve; fork-points for already-rebased branches are saved so re-running
wt syncpicks up where it left off - Non-zero exit on conflict — so
wt sync && wt sync --pushwon't silently push past a conflict
- Git with worktrees (
git worktree add) - worktrunk >= 0.35 (runtime dependency for repository utilities)
cargo build
cargo test
cargo clippy --all-targets -- -D warningsInstall pre-commit and enable hooks:
pip install pre-commit
pre-commit installHooks run automatically on each commit (rustfmt, clippy, typos, trailing whitespace, etc.). To run manually:
pre-commit run --all-files- Bump the version in
Cargo.toml - Commit and tag:
git add Cargo.toml Cargo.lock git commit -m "release: v0.2.0" git tag v0.2.0 git push && git push --tags
- The release workflow will automatically:
- Build and test
- Publish to crates.io
- Create a GitHub release with auto-generated notes
MIT