Skip to content

Intermittent MergeFetchHeadNotFoundException #2175

@miloush

Description

@miloush

I am getting intermittent

LibGit2Sharp.MergeFetchHeadNotFoundException: The current branch is configured to merge with the reference 'refs/heads/main' from the remote, but this reference was not fetched.
   at LibGit2Sharp.Repository.MergeFetchedRefs(Signature merger, MergeOptions options) in /_/LibGit2Sharp/Repository.cs:line 1268
   at LibGit2Sharp.Commands.Pull(Repository repository, Signature merger, PullOptions options) in /_/LibGit2Sharp/Commands/Pull.cs:line 37

when calling Commands.Pull on https://github.com/unicode-org/unicodetools. Clearly the remote ref (main branch) has been there for a while and is not going anywhere. Trying pull again usually succeeds without an exception.

Any other reason why this error would happen, or is there some logging I could turn on to figure out what's going on? For example, what refs does it see (my guess would be none). I don't have a reliable repro, never happened on my local machine, happens uncomfortably often on a server machine.

The clone is for reading only, the point is to just keep it up to date, i.e. there is no local changes to merge ever, so I use these options:

pullOptions.MergeOptions = new MergeOptions();
pullOptions.MergeOptions.SkipReuc = true;
pullOptions.MergeOptions.FastForwardStrategy = FastForwardStrategy.FastForwardOnly;

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