2

I have worked with git submodules in the past. I know the basic functionality. If I simply used git submodule add <repo-url> <path/to/submodule>, the .gitmodules file would have :

[submodule "path/to/submodule"]
        path = path/to/submodule
        url = <repo-url>.git

Recently, I had to add a new git submodule to a repository that I was working on. I also found the fancy --name flag that can be used with the git submodule add command, from the man page of git submodule. The add worked fine and my .gitmodules had :

[submodule "<submodule-name>"]
        path = path/to/submodule
        url = <repo-url>.git

The issue happens when I'm attempting to update the submodule from the remote :

$ git submodule update --remote
fatal: no submodule mapping found in .gitmodules for path 'path/to/submodule'

OK, I can read the log, so I provide the path/to/submodule next :

$ git submodule update --remote path/to/submodule
Submodule path 'path/to/submodule' not initialized
Maybe you want to use 'update --init'?

OK, if you say so ( though I'm sure that the submodule has been properly initialized before already ). Now :

$ git submodule update --init --remote path/to/submodule
fatal: No url found for submodule path 'path/to/submodule' in .gitmodules

I did some experiments on a test repository and found that this happens only when the submodule is 'named'.

Am I doing something wrong with the name thing of the submodule? According to the man page, the --name flag is only applicable for the add sub-command and it does not work with update.

How do I update such named submodules?

shine
  • 103
  • 1
  • 5
  • What version of git are you using? – VonC Aug 18 '20 at 05:54
  • git version 2.25.1 – shine Aug 18 '20 at 06:55
  • Would that persists with 2.28? – VonC Aug 18 '20 at 07:18
  • I was using the version that I got from the operating system's package repositories. I'll have to compile the latest version and then compare. However, a quick look at the history of `git/submodule.c`, didn't indicate any major changes to the functionality. – shine Aug 18 '20 at 09:09
  • What is the OS? 2.26 added an interesting feature (https://stackoverflow.com/a/18799234/6309). For Linux, see http://lifeonubuntu.com/upgrading-ubuntu-to-use-the-latest-git-version/ for upgrade. 2.27 also impacted submodule: https://stackoverflow.com/a/60905327/6309/ And git 2.28: https://stackoverflow.com/a/18799234/6309 – VonC Aug 18 '20 at 09:23
  • thanks. yes, I am on GNU/Linux. the changes that have been pointed out doesn't seem to be related to the `--name` flag. Nevertheless, I am going to upgrade to the latest version and try again ( I was already in the process ). – shine Aug 18 '20 at 10:02
  • I upgraded to the latest `git version 2.28.0` and the same issue persists there as well. – shine Aug 18 '20 at 18:22
  • That looks like a job for the recent git bugreport tool then. (Towards the end of https://stackoverflow.com/a/10733251/6309) – VonC Aug 18 '20 at 20:16
  • thanks for indicating that it might be a bug; I'll raise a bug report for this. – shine Aug 18 '20 at 20:41
  • Great! Let me know of the mailing list link you will create; I will keep an eye on that thread. – VonC Aug 18 '20 at 20:42

0 Answers0