Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change a submodule's name?

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 = [email protected]: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 = [email protected]:onassar/PHP-Pixabay.git

Thanks!

like image 258
onassar Avatar asked Apr 10 '19 14:04

onassar


People also ask

Can you edit a git submodule?

Make changes inside a submodulegit commit the new changes. git push the new commit. cd back to the main repository. In git status you'll see that the submodule directory is modified.

How can I update one submodule?

In order to update an existing Git submodule, you need to execute the “git submodule update” with the “–remote” and the “–merge” option. Using the “–remote” command, you will be able to update your existing Git submodules without having to run “git pull” commands in each submodule of your project.

How do I manage git submodules?

Use the git submodule update command to set the submodules to the commit specified by the main repository. This means that if you pull in new changes into the submodules, you need to create a new commit in your main repository in order to track the updates of the nested submodules.


1 Answers

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
like image 104
phd Avatar answered Sep 28 '22 21:09

phd