progit2 icon indicating copy to clipboard operation
progit2 copied to clipboard

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

Open Fingerling42 opened this issue 1 month ago • 0 comments

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

Fingerling42 avatar Nov 06 '25 13:11 Fingerling42