Have you ever wanted to replace a git submodules in a repository but don’t know where to start? You are in luck. In this tutorial, I am going to show you how I would do it.
It is actually pretty simple as long as you have added the submodules correctly in the first place.
This means that you added your submodules like this,
One might think that you could do something like this,
However, it does not work like that as the list of available git submodule commands does not include replace except these,
Then, how would one replace it?
You simply need to modify one file, then you are done.
Take a look at your file .gitmodules in the root of your repository, it will probably look something similar to this,
source code hosted on GitHub
Now, all you need to do is to change the repository url to the one you want. Also, you might need to change the path to your submodules in case of any submodules name changes.
That is it! All that is left with was commiting your changes.
Tada. Your project should now have a new submodules =)
Wrapping Up
Hopefully this guide has help you to replace a git submodules in a repository. Thank you for reading!
Resources
I’ll try to keep this list current and up to date. If you know of a great resource you’d like to share or notice a broken link, please let us know.
Comments