Skip to content

Pull with rebase fails when the upstream moved a submodule to a new commit #89

Closed

Description

@ChrisLauinger77

What happened?

Pull with rebase fails when the upstream moved a submodule to a newer commit and the branch has local commits. The pull stops with:

unstaged changes exist in workdir; class=Rebase (29); code=Unmerged (-10)

The repository is left in the middle of a rebase, with HEAD detached. Continue rebase fails with the same error, so the only way out is to abort.

Expected: like git pull --rebase, the local commits are replayed on top of the upstream. Git leaves the submodule folder at its old commit and reports it as modified (M deps/lib) until you update it.

Likely cause: libgit2 checks the working tree again in rebase.commit() (rebase_commit_merge → rebase_ensure_not_dirty(…, false, true, GIT_EUNMERGED)). After the rebase checks out onto, the index records the submodule's new commit, but nothing updated the submodule folder. libgit2 therefore sees the submodule as an unstaged change and refuses every commit of the replay. git rebase doesn't treat the submodule that hasn't been updated yet as a change, which is why the same steps work there.

The same failure applies to a plain rebase onto any branch that moves a submodule's recorded commit, not only to a pull.

Steps to reproduce

  1. Use a repository with an initialized submodule (for example at deps/lib) that is checked out at the recorded commit.
  2. On the upstream, commit a new submodule commit (the submodule moves from lib one to lib two) and push.
  3. Locally, make an unrelated commit (for example, edit README.md).
  4. Choose Pull with rebase (or Pull with pull.rebase = true). It fails with the error above, and the toolbar shows a rebase in progress.
  5. Choose Continue rebase. It fails with the same error.

The same steps with git pull --rebase (git 2.56) succeed. They end with local edit on top of bump lib, and git status shows M deps/lib.

I reproduced this through the engine functions the UI calls (remote::pull in rebase mode, then rebase_continue), using the test suite's submodule fixture, not by clicking through the app. The rebase code path is the same on main (0.26.0, 34126e1).

AngKorGit version

0.26.0 (main at 34126e1)

Operating system

macOS. The code path doesn't depend on the OS.

Repository shape (if relevant)

Needs an initialized submodule whose recorded commit changes between the local branch and the branch it is rebased onto.

Found while testing #87; it isn't related to hooks. Related to #88, which covers another way Continue rebase misbehaves after a replay step fails.

Activity

  1. ChrisLauinger77 commented on Nov 13, 2026

    @ChrisLauinger77
    ContributorAuthor

    @cheat2001 I can have a look at this after #91 is merged it is OK for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions