Conversation
skarim
added this pull request to stack #530
September 28, 2026 17:20
skarim
force-pushed
the
skarim/worktrees-distributed-rebase-sync
branch
from
September 28, 2026 21:37
9bedee9 to
044def4
Compare
This was referenced Sep 29, 2026
skarim
marked this pull request as ready for review
September 29, 2026 16:28
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Legacy recovery can clear journals after partial restoration, and ambiguous stack selection can lose the caller’s original checkout.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Enables rebase and sync to safely operate across multiple Git worktrees with shared recovery state.
Changes:
- Adds owner-scoped rebase execution, continuation, rollback, and pruning.
- Pins trunk targets and disables automatic Git maintenance during rebases.
- Updates tests and documentation for distributed workflows.
| File | Description |
|---|---|
cmd/rebase.go |
Routes distributed rebase and recovery. |
cmd/rebase_worktree.go |
Implements worktree-aware recovery. |
cmd/rebase_test.go |
Tests distributed rebase behavior. |
cmd/sync.go |
Adds cross-worktree sync and pruning. |
cmd/sync_test.go |
Tests distributed sync and rollback. |
cmd/utils.go |
Adds scoped fast-forward and cascade helpers. |
cmd/trunk_target_test.go |
Updates trunk and rollback tests. |
cmd/worktree_utils.go |
Validates shared recovery journals. |
internal/worktree/context.go |
Supports owner-scoped operations. |
internal/git/git.go |
Disables maintenance during rebases. |
internal/git/gitops_test.go |
Verifies maintenance isolation. |
internal/git/worktree_test.go |
Updates rebase argument expectations. |
internal/stack/lock.go |
Clarifies operation-lock behavior. |
internal/config/config.go |
Simplifies mutation context. |
README.md |
Documents cross-worktree operation. |
docs/src/content/docs/reference/cli.md |
Updates CLI recovery guidance. |
docs/src/content/docs/guides/workflows.md |
Documents distributed workflows. |
docs/src/content/docs/getting-started/quick-start.md |
Updates quick-start constraints. |
skills/gh-stack/SKILL.md |
Updates skill constraints. |
skills/gh-stack/references/commands.md |
Documents command behavior. |
skills/gh-stack/references/troubleshooting.md |
Updates worktree troubleshooting. |
AGENTS.md |
Updates repository architecture guidance. |
.github/copilot-instructions.md |
Updates contributor instructions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
skarim
force-pushed
the
skarim/worktrees-distributed-rebase-sync
branch
from
September 29, 2026 22:47
468ad50 to
2347413
Compare
skarim
force-pushed
the
skarim/worktrees-distributed-rebase-sync
branch
from
September 29, 2026 23:14
2347413 to
f17be93
Compare
skarim
force-pushed
the
skarim/worktrees-distributed-rebase-sync
branch
from
September 29, 2026 23:57
f17be93 to
9931fd7
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Enables
gh stack rebaseandgh stack syncto update branches checked out in different worktrees. Building on shared tracking from #528, each change runs in the checkout that holds the branch, so users no longer need to move the whole stack into one directory.Functionality and user impact
--continueand--abortcan run from any worktree because a shared recovery file records where the operation ran and what it changed. If recovery cannot finish, keep that file for another attempt.Boundary: rollback covers the stack rebases, not earlier fetches or completed fast-forwards. Requires Git 2.36+, with no automatic stashing or worktree creation/removal. Distributed modify follows in #521. Operations paused on the earlier
origin-onlyversion must finish with that matching build.Key areas to review
cmd/rebase.go/cmd/sync.go:runRebaseandrunSyncidentify the worktrees needed before changing branches. Follow sync's error handling to ensure it does not push partial results or prune a branch still checked out elsewhere.cmd/utils.go:planFastForwardBranches,fastForwardBranches, andresolveTrunkTargetchoose which branches can advance.rebaseStep/cascadeRebasechoose the commits to replay and save progress before invoking Git.cmd/rebase_worktree.go:continueWorktreeRebase,rollbackWorktreeRebase, andpublishCompletedRebaseresume or undo the recorded work, then save the catalog before removing the recovery file. Incompatible recovery records are rejected incmd/rebase.gobefore reaching these functions.internal/worktree/context.go:Prepare,Start,Record, andRestoretrack the branch commits before and after each change. Abort uses these records rather than blindly resetting every branch in the stack.internal/git/git.go:rebaseArgsdisables automatic maintenance for rebase commands so backgroundrerere gccannot race conflict handling. Repository settings and unrelated Git commands are unchanged.Related issues
gh stack rebasesilently succeeds whengit rebase --ontofails to start (in branch checked out in another worktree) #35Part 4 of the 4-PR split of #520