Skip to content

Mention the issue when the branch names of the submodules and superproject differ #2060

@Fingerling42

Description

@Fingerling42

General overview of your idea.

The Publishing Submodule Changes section describes how to use the git push --recurse-submodules=on-demand command, which should push the submodules changes first, then the main project changes.

However, as of Git v2.51.2, it will not work if the names of the superproject and submodules branches are different. The error is something like this:

fatal: src refspec 'refs/heads/main' must name a ref
fatal: process for submodule 'simple_git_project' failed

In this case, the superproject branch was called main, and the submodule branch was called master.

I don't know what Git maintainers think about it, but the problem is quite old (here's a mention on Stack Overflow).

It might be helpful to add a short note clarifying that in Pro Git.

What problem will this solve?

This will save the reader from two hours of confusion when a command fails for a not-so-obvious reason.

Have you thought about other solutions?

No response

Do you want to help with this enhancement idea?

Maybe

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions