This is good, because your code might not Submodule's code won't automatically be updated if the submodule's This informationĭescribes which commit the submodule is pointing at. Submodule that is added to the main repository. Submodule to the main repository, you only add information about the When you add a submodule in Git, you don't add the code of the This is a lot more convienient than copy-pasting the code into the With this approach you can easily update that sharedĬomponent in all the repositories that added them as a submodule. Useful if you have multiple repositories that share a commonĬomponent. Re-use the submodule in multiple parent repositories. This way you'll have aĬleaner Git log, because the commits are specific to a certain You can make every subproject a submodule. Useful if you have a big project that contains multiple subprojects. Separate big codebases into multiple repositories. Repository embedded in your main repository. In Git you can add a submodule to a repository. Take the time to learn how to use Submodules and you will find them easy to use and very helpful in the right situations.Git Submodules basic explanation Why submodules? Each Submodule should be treated as a completely seperate repository to get the most sence out of using Git Submodules. Git Submodules are a great way to distribute several repositories all as one. If you ever plan on merging submodules into the main repository, this is possible but its probably better to not use submodules in the first place. Git Submodules add complexity to your version control system and you should ensure using Submodules is more of a benefit than that complexity. To see the full list of options, please read the Git Submodules onlne man pages. In the man repository you can now see a directory called … 1 In the root of the main repository, you add a submodule using the git submodule add command as follows: 1 To start using git submodules you first need a Git repository, this can be a new repository or an existing one. Rather than pull all the code into one repository, submodules means that updates from the other projects are easily incorporated into the main Prezto project. The Prezto project pulls in several other projects, each of which configures specific features of Zsh. I use a project calle Prezto which provides a great setup for using Zsh. Prezto: A bigger example of submodules in actions I also have an existing repository for a series of developer guides I created, which I can also add as a sub-module and still keep that repository seperate for those who wish to only work with my guides (and not my full content). I can create a history of changes to the theme and roll back if there are bugs without having to worry about dropping content changes. So by forking the Hexo defalut theme into a seperate repository, I can then add the theme repository as a submodule of my content repository. However, I didnt want to add the theme or my changes to the repository I am managing all my content, as I dont want to tie the content to a particular platform. I started using a Git Submodule with my project as I wanted to make significant changes to the default theme that Hexo uses. The generated site is also deployed as a Github Pages site. I create all my content in markdown and push it to a github repository as a backup. I use Hexo.io, a static site generator, to create this blog you are reading. My blog: A simple example of Git Submodules When you clone or pull a repository with a submodule, the repository has a link to where to get the submodle code from. Each repository maintains its own seperate change history and submodules are updated independently of the main repository. Git Submodules allow you to share two or more repositories as though they were one. For example, you may be using a library that is under active development and you need to develop you code along with any changes. Submodules are useful if you have a code or content in one git repository that you want to use with several other git managed projects, yet you still want to keep the change history seperate. You can have many submodules within a git repository and even have submodules in a submodule. Submodules are not clones or branches of a single repository and I would advise against merging submodules into the main repository. Actually its a full and seperate git repository itself with its own commit history. Git Submodules OverviewĪ submodule appears to be just a subdirectory of another git repository. I’ll explain what Git Submodules as well as why some developers are using them and some developers warn you not to. I have used them successfully and when you understand where they fit in you can use them to benefit your own projects too. Git is the version control system of choice by most developers, however when it comes to Git Submodules there is some contention as to their value.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |