BLACK LABELAcademy
← Our Failures

Local main can silently fork from origin (unpushed + unpulled commits)

intermediate5 min read · updated 2026-06-20

Market & numbers — every figure sourced

local_commits_unpushed7 commitsest: Observed count from our own incident: local main held 7 commits never pushed to origin/main
remote_commits_unpulled8 commitsest: Observed count from our own incident: origin/main held 8 commits (incl. a merged PR with the revenue path) never pulled locally

Local main can silently fork from origin (unpushed + unpulled commits)

A repo's local `main` and `origin/main` can drift apart without any error, any warning, or any obvious sign — until you try to push and Git refuses, or worse, until you commit on top of a base that no longer matches reality. This is a quiet failure mode that wastes hours and occasionally loses work. Here is exactly how it bit us, why it happens, and the workflow that prevents it.

What we tried

We treated local `main` as if it were always a faithful mirror of the remote. We made commits directly on `main`, assumed `git status` saying "working tree clean" meant we were in sync, and started new feature work straight off whatever local `main` happened to be.

In one incident, local `main` had drifted to 7 commits that were never pushed to `origin/main`, while `origin/main` had moved ahead by 8 commits we had never pulled — including a merged pull request that carried the revenue path. Neither side knew about the other.

What broke

The root cause: nothing forces local and remote to stay aligned. `git fetch` updates remote-tracking refs (`origin/main`) but never touches your local branch, and `git commit` never consults the remote at all. Drift is the default; alignment is a deliberate act.

The fix

1. Always fetch and inspect before you commit or branch on `main`.

```bash

git fetch origin

git status -sb # shows "ahead N, behind M" vs upstream

git log --oneline --graph origin/main...HEAD # see exactly what diverged

```

`git fetch` is read-only and safe — it updates `origin/main` without altering your work (Julia Evans).

2. Reconcile deliberately, with intent — never by reflex.

3. Stop committing on `main` at all. Branch feature work off the freshly synced remote.

```bash

git fetch origin

git switch -c feature/my-thing origin/main # base on REMOTE main, not local

```

Basing the branch on `origin/main` guarantees a real base even if your local `main` is stale.

4. Make the safe default permanent.

```bash

git config --global pull.ff only # refuse silent merge/rebase on a diverged pull

```

This turns the silent failure into a loud, recoverable one: a diverged `pull` stops and tells you, instead of guessing (git-pull docs).

Apply it

Sources

© 2026 Black Label · Education, not financial or legal advice. Every number is sourced or labeled an estimate. Subscribe for $30/month