git submodule init has extend behavior in which it accepts a list of explicit module names. 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. Again this works when updates are not too frequent. When you are delegating a piece of the project to a third party and you want to integrate their work at a specific time or release.When you have a component that isn’t updated very often and you want to track it as a vendor dependency.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. 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. When you are inside the submodule, you can treat it just like a normal repo, and when you are in the parent repository, you can "add" to change the current commit pointer.īut the traditional downside is that you either have to have your users know git submodule commands, so they can init and update the repo, or they have to add -recursive when they initially clone your repo.Git submodules allow you to keep a git repository as a subdirectory of another git repository. The relative path to the repo is important it allows you to keep the same access method (ssh or https) as the parent repository. If you want to add a Git repository on the same service (GitHub, GitLab, BitBucket, etc), the following is the correct Git command to set that up as a submodule in the extern directory: gitbook $ git submodule add.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |