How to make a submodule

Hi,
I’m a beginner for github. I want to remove a framework folder (lets say folder A) and make it as a submodule for my codebase and apply folder A for my future codebases as well. How to do that?

regards,
V.

Submodules seem the right solution from what you wrote. I.e. hosting another repository inside your repository, as a subfolder (named as you like) which points to the other repository (the hosted submodule).

The “How to” requires that you read a full tutorial, because Git submodules can be a bit tricky to understand and setup/use correctly, since there are different update strategies involved regarding when/if and how the submoduled repository should be updated — which ultimately depends on your project’s needs.

I suggest you read this good introductory tutorial:

Once you’ve understood all the implications, the various options and all the pros and cons, you should be safe to experiment with submodules locally, before attempt using them in a productions repository.

The tricky part is learning how to handle updates in the submodule, i.e. updating its “pointer” (to a commit, tag, or some other -ISHy reference). These changes have to be always commited in your repository, since they are part of your repository history (a pointer to another repo, that’s all there is to a submodule as far as your repository is concerned).

This last aspect has to be kept in mind when working with branches, for it’s easy to forget about changes in submodules pointers and cause the submodule to revert to a previous pointer during branch operations.