Skip to content

mob start can silently discard local commits if branch has unpushed changes #478

@pfichtner

Description

@pfichtner

Summary (TL;DR)

If a developer forgets to run mob start before making changes, then runs mob next, Mob creates a local commit.
If they then run mob start to catch up with the latest mob session, Mob force-resets the branch to origin/mob/main and silently discards the local commit.
The work is only recoverable via git reflog.

This is different from a push rejection: the problem is mob start always doing a hard reset.


Environment

  • Mob version: 5.4.2

Scenario (Step-by-step)

Dev A (correct flow)

  1. mob start
  2. make changes
  3. mob next # pushes successfully

Remote mob/main moves forward.

Dev B (forgot to run mob start)

  1. Already on the mob/main branch
  2. Starts working without mob start.
  3. Makes changes locally.
  4. Runs mob next:
  • Local commit exists on mob/main.
  • Push get rejected b/c remote advanced — but the commit is still in the local branch.
  1. Dev B runs mob start to "catch up":
  • Force-reset happens.
  • The local commit from mob next is deleted from the branch and working tree.
  • Only recoverable via git reflog.

Why this is problematic

  • The push rejection is not the root cause; it’s just a common trigger.
  • The real problem: mob start always resets the branch, regardless of local commits.
  • This makes the workflow fragile, and it’s easy for developers to lose work silently.

Expected behavior

mob start should detect local commits not on the remote and refuse to reset blindly.

Example:

“You have local commits on mob/main not on origin/mob/main. Please pull/rebase/push your changes before running mob start.”

Alternatively, provide an option to rebase local commits instead of overwriting them.


Suggested improvements

1) Safety check before reset

git log origin/mob/main..mob/main

If non-empty → abort mob start with clear instructions.

2) Guidance after failed mob next

When the push fails:

“Your commit exists locally but is not pushed. Run git pull --rebase origin mob/main and then mob next. Do not run mob start before resolving divergence.”

3) Optional rejoin-local mode

mob start --rejoin-local

Automatically rebase local commits onto origin/mob/main instead of discarding them.


Why this matters

Mob abstracts Git for collaboration. In this case, that abstraction hides a destructive Git operation, leading to silent data loss.
A simple safety check would prevent this from happening in real-world sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions