Skip to content

feat(sync): add --cross-worktree flag to sync branches across worktrees#81

Merged
javoire merged 2 commits into
mainfrom
jd/sync-cross-worktree
May 20, 2026
Merged

feat(sync): add --cross-worktree flag to sync branches across worktrees#81
javoire merged 2 commits into
mainfrom
jd/sync-cross-worktree

Conversation

@javoire
Copy link
Copy Markdown
Owner

@javoire javoire commented May 7, 2026

Summary

  • Adds WithDir(path) GitClient to the git client interface — returns a scoped client that prepends git -C <path> to all commands
  • stack sync --cross-worktree rebases branches checked out in other worktrees in-place instead of skipping them
  • Uses the scoped client for working-tree operations (rebase, reset, cherry-pick) while ref-only operations (push, fetch) use the main client
  • Conflict resolution messages include cd <worktree-path> so users know where to resolve
  • Cherry-pick rebuild is disabled for cross-worktree branches (git refuses to delete a branch checked out in a worktree)
  • Without the flag, skip messages now hint about --cross-worktree

🤖 Generated with Claude Code

javoire and others added 2 commits May 7, 2026 19:44
Adds WithDir(path) to the GitClient interface, which returns a scoped
client that prepends `git -C <path>` to all commands. When --cross-worktree
is passed to `stack sync`, branches checked out in other worktrees are
rebased in-place via the scoped client instead of being skipped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Persist conflict worktree path to git config so --abort can create a
  dir-scoped client and abort the rebase in the correct worktree
- Warn when --cherry-pick is skipped for cross-worktree branches instead
  of silently falling through
- Guard ResetToRemote with dirty-worktree check for cross-worktree
  branches to prevent destroying uncommitted changes
- Fix stdout/stderr inconsistency for informational messages

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@javoire javoire marked this pull request as ready for review May 8, 2026 00:01
@javoire javoire merged commit 2a50827 into main May 20, 2026
1 check passed
@javoire javoire deleted the jd/sync-cross-worktree branch May 20, 2026 20:45
javoire pushed a commit that referenced this pull request May 20, 2026
…026-05-20)

### Features

* **sync:** add --cross-worktree flag to sync branches across worktrees ([#81](#81)) ([2a50827](2a50827))
@javoire
Copy link
Copy Markdown
Owner Author

javoire commented May 20, 2026

🎉 This PR is included in version 1.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant