![git add remote submodule git add remote submodule](https://i.stack.imgur.com/LkXhc.png)
#Git add remote submodule update
When making changes to a submodule it is important to publish submodule changes and then update the parent repositories reference to the submodule. This means that submodules have their own branches and history. Once submodules are properly initialized and updated within a parent repository they can be utilized exactly like stand-alone repositories. This can be helpful if there are many submodules in a repo but they don't all need to be fetched for work you are doing. This enables a workflow of activating only specific submodules that are needed for work on the repository. git submodule init has extend behavior in which it accepts a list of explicit module names.
![git add remote submodule git add remote submodule](http://www.crmkonsulterna.se/app/uploads/2020/04/13-Checkout-submodule-master-1024x576-1.png)
This may seem redundant and lead to questioning git submodule init usefulness. The default behavior of git submodule init is to copy the mapping from the. Git clone /url/to/repo/with/submodules git submodule init git submodule update Git submodule Init The following is an example that creates an empty repo and explores git submodules. The git submodule add is used to add a new submodule to an existing repository.
![git add remote submodule git add remote submodule](https://i.stack.imgur.com/vCasr.png)
Again this works when updates are not too frequent.
#Git add remote submodule code
When an external component or subproject is changing too fast or upcoming changes will break the API, you can lock the code to a specific commit for your own safety.The following are a few best use cases for git submodules. If you need to maintain a strict version management over your external dependencies, it can make sense to use git submodules. gitmodules file will have an entry for each submodule. If the host repository has multiple submodules, the. gitmodules file contains meta data about the mapping between the submodule project's URL and local directory. When adding a submodule to a repository a new. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated. Submodules are very static and only track specific commits. Both of these suggested incorporation methods do not enable tracking edits and changes to the external repository.Ī git submodule is a record within a host git repository that points to a specific commit in another external repository. This method has the downside of requiring installation and version management at all places the origin code is deployed. Another method of incorporating external code is through the use of a language's package management system like Ruby Gems or NPM. This method has the downside of losing any upstream changes to the external repository. The external code can be directly copied and pasted into the main repository.
![git add remote submodule git add remote submodule](https://media.vlpt.us/images/wnduq8/post/77b70f79-4362-4525-ade5-7416b23d8bbc/image.png)
This external code can be incorporated in a few different ways. Often a code repository will depend upon external code. Git submodules enable a Git repository to incorporate and track version history of external code. Git submodules are simply a reference to another repository at a particular snapshot in time. Git submodules allow you to keep a git repository as a subdirectory of another git repository.