Skip to content

Fix bare pull aborting on a divergent branch#77

Merged
danipen merged 2 commits into
mainfrom
fix-pull-diverged
Jul 4, 2026
Merged

Fix bare pull aborting on a divergent branch#77
danipen merged 2 commits into
mainfrom
fix-pull-diverged

Conversation

@danipen

@danipen danipen commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Problem

When a branch is both ahead and behind its upstream (diverged), the toolbar surfaces Pull as the primary action (it checks behind > 0 before ahead > 0). Clicking it runs a plain git pull.

Since git 2.27, a bare git pull that can't fast-forward aborts:

fatal: Need to specify how to reconcile divergent branches.

…unless a reconciliation strategy is pinned (pull.rebase, pull.ff, or a flag). With none configured, the user is stranded: Pull keeps failing, and Push is blocked for being behind — no obvious way out.

Fix

Default a non-rebase pull to --ff (fast-forward when possible, merge when diverged) unless the user has set pull.ff themselves. That's enough to satisfy git's reconciliation check while respecting an explicit config; pull.rebase, if set, git still honours over --ff. The pull --rebase path is untouched (it already pins a strategy).

Tests

Adds sync.test.ts — an integration test driving the real git binary against a throwaway diverged clone:

  • a bare pull now reconciles with a merge instead of aborting (regression guard — fails with the exact fatal without the fix)
  • pull.ff=only is respected: the divergence is left to the user

🤖 Generated with Claude Code

danipen added 2 commits July 4, 2026 18:09
The toolbar surfaces Pull the instant a branch is behind, so an
ahead+behind (diverged) branch runs a plain `git pull`. Since git 2.27
that aborts with "fatal: Need to specify how to reconcile divergent
branches" unless a strategy is pinned, stranding the user: Pull keeps
failing and Push is blocked for being behind.

Default a non-rebase pull to `--ff` (fast-forward when possible, merge
when diverged) unless the user has set pull.ff themselves — enough to
satisfy git's reconciliation check while respecting an explicit config.

Adds an integration test covering both the divergent merge and the
pull.ff=only opt-out.
@danipen danipen merged commit 8c1b097 into main Jul 4, 2026
9 checks passed
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