3

I've spent a considerable amount of time reading through this: Rename a git submodule

However my case is actually a bit different. I've already renamed/moved the submodules, but I've noticed that the "name" of the module is the name I initially had when I first added the module.

I believe the --name property can only be used when a module is initially added. But just incase, I thought I'd ask:

Can I change the "name" of the module once it's already been moved? I want to have the entry in the .gitmodules and .git/config changed, as well as the directory structure inside of .git/modules/*

I'm trying to prevent having to remove the modules (there's quite a few) and then re-add them all.

For reference, here's what a current module record in my .gitmodules file looks like:

[submodule "TurtlePHP/application/vendors/PHP-Pixabay"]
    path = TurtlePHP/application/vendors/submodules/PHP-Pixabay
    url = git@github.com:onassar/PHP-Pixabay.git

And here's what I want it to be:

[submodule "TurtlePHP/application/vendors/submodules/PHP-Pixabay"]
    path = TurtlePHP/application/vendors/submodules/PHP-Pixabay
    url = git@github.com:onassar/PHP-Pixabay.git

Thanks!

onassar
  • 2,776
  • 6
  • 32
  • 48

1 Answers1

0

I think renaming sections in .git/config and .gitmodules is just fine:

git config                --rename-section submodule.TurtlePHP/application/vendors/PHP-Pixabay submodule.TurtlePHP/application/vendors/submodules/PHP-Pixabay
git config -f .gitmodules --rename-section submodule.TurtlePHP/application/vendors/PHP-Pixabay submodule.TurtlePHP/application/vendors/submodules/PHP-Pixabay
phd
  • 57,284
  • 10
  • 68
  • 103
  • What about the actual directory structure within `/.git/modules`? – onassar Apr 11 '19 at 13:55
  • In the context of CLI/git commands, renaming/moving a module is different than changing it's name. Renaming/moving moves the directory and references within `.gitmodules` and `.git/config`, whereas _changing the name_ changes the name associated with that submodule. – onassar Apr 12 '19 at 15:22
  • The linked question has many good answers, aren't they enough? Just a week ago a I restructured and renamed a submodule from `xxx-yyy` to `xxx/yyy`. It was really simple. – phd Apr 12 '19 at 16:49
  • Moving/renaming a submodule is different than actually changing the module's `name`. Have you looked into the `.gitmodules` file, and checked out the name? It's possible (but not 100%) that the name itself it incorrect, if the name was originally defined to be the relative path to the submodule. – onassar Apr 13 '19 at 17:09