Skip to content

fix(MORG-48): sync without checking out branches#37

Merged
developerdavi merged 1 commit intomainfrom
MORG-48
Mar 9, 2026
Merged

fix(MORG-48): sync without checking out branches#37
developerdavi merged 1 commit intomainfrom
MORG-48

Conversation

@developerdavi
Copy link
Copy Markdown
Owner

@developerdavi developerdavi commented Mar 9, 2026

Closes MORG-48

Summary

  • Step 1 (pull default branch): when not already on the default branch, uses git fetch origin main:main (via the existing fetchAndUpdateBranch helper) instead of checkout → pull → checkout. This updates the local branch ref without switching to it.
  • Step 4 (rebase/merge): removes the checkout-away/back pattern. For non-current branches with a worktree, passes cwd: branch.worktreePath to rebaseBranch/mergeBranch so git operates in the right directory. For non-current branches without a worktree, skips with an informational message ("switch to it to update").
  • rebaseBranch and mergeBranch in git/index.ts each gain an optional cwd parameter to enable the above.

What's unchanged

  • The deletion case (Step 3) still checks out the default branch when the current branch is being deleted — this is the accepted exception per the acceptance criteria.

Test plan

  • morg sync from a feature branch — should pull latest main without ever switching to main
  • morg sync --all with multiple active branches that have worktrees — rebase/merge runs in each worktree's directory, user stays on current branch
  • morg sync --all with a non-current branch that has no worktree — shows "switch to it to update" message and skips
  • morg sync when current branch is deleted during sync — correctly checks out default branch (exception case)
  • All 45 existing tests pass (pnpm test)

Use `git fetch origin main:main` to update the local default branch ref
without checkout. For non-current branches in --all mode, run rebase/merge
in their worktree directory (via cwd) instead of switching to them; branches
without a worktree are skipped with a message to switch manually.
@developerdavi developerdavi merged commit aabcae3 into main Mar 9, 2026
1 check passed
@developerdavi developerdavi deleted the MORG-48 branch March 9, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant