{"id":2722,"date":"2022-04-21T14:33:10","date_gmt":"2022-04-21T14:33:10","guid":{"rendered":"https:\/\/gitprotect.io\/blog\/?p=2722"},"modified":"2025-06-13T07:43:23","modified_gmt":"2025-06-13T07:43:23","slug":"managing-git-projects-git-subtree-vs-submodule","status":"publish","type":"post","link":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/","title":{"rendered":"Managing Git Projects: Git Subtree vs. Submodule"},"content":{"rendered":"\n<p>While working on a project, it&#8217;s common to have it combined with another one, especially if you work in a network with other people. It might be a library built by other developers, or a piece of the project developed independently and then reused in several projects. When such a thing happens, you want to keep both projects distinct yet you want to be able to use one of them in a different one. This post was written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best for you.<\/p>\n\n\n\n<!--more-->\n\n\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is&nbsp;git submodule<\/strong><\/h2>\n\n\n\n<p>A Git submodule is a separate repository within a repository, to put it simply. Project management is advantageous in a variety of ways. A submodule is similar to a child repository in a way that pointer commits must be manually updated. They are easy for a team to work together at the same time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Why should I use submodules?<\/strong><\/h3>\n\n\n\n<p>You don&#8217;t clone or integrate any of the actual code in your new repository when you use many submodules, it&#8217;s better to say that you include links to the forest repository on GitHub. These pointers lead to a submodule commit in a different repository.<\/p>\n\n\n\n<p>Git submodules enable you to preserve one git repository as a sub directory of another. Also, Git submodules allow you to include and track the version history of external code in your Git repository.<\/p>\n\n\n\n<p>Git&#8217;s basic package includes submodules that allow Git repositories to be nested within other separate repositories. The Git submodule, to be exact, corresponds to a specific commit on the child repository.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Scenarios where submodules are useful<\/h3>\n\n\n\n<p>To manage the versioning of external dependencies for a project, you can use the Git submodules feature. For example, here are some scenarios in which you can use git submodules:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can lock the code to a specific commit for your own safety when an external component or subproject is changing too quickly or forthcoming modifications would break the API.<\/li>\n\n\n\n<li>When you wish to track a vendor dependence for a component that isn\u2019t automatically updated too often.<\/li>\n\n\n\n<li>When you delegate a project component to a third party and wish to include their work at a certain time or release. When the changes aren\u2019t too frequent, this method works well.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/gitprotect.io\/sign-up.html\"><img decoding=\"async\" width=\"1024\" height=\"536\" src=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-1024x536.png\" alt=\"Get free GitProtect trial\" class=\"wp-image-2555\" style=\"width:500px;height:auto\" srcset=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-1024x536.png 1024w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-300x157.png 300w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-768x402.png 768w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-400x209.png 400w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">How to use git submodules?<\/h3>\n\n\n\n<p>Firstly, create a new submodule using the git submodule command that saves the path and hyperlink references in a folder called .gitmodules.<\/p>\n\n\n\n<p>For example, to clone a repository with submodules, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git clone --recursive &lt;URL to Git repo&gt;<\/em><\/code><\/pre>\n\n\n\n<p>If you&#8217;ve previously cloned a repository and wish to load its submodules, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git submodule update --init<\/em><\/code><\/pre>\n\n\n\n<p>If there are nested submodules, do the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git submodule update --init --recursive<\/em><\/code><\/pre>\n\n\n\n<p>Specify a branch for a submodule using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git submodule set-branch -branch &lt;branch name&gt; -- &lt;submodule path&gt;<\/em><\/code><\/pre>\n\n\n\n<p>Or change branch using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git submodule change branch<\/em><\/code><\/pre>\n\n\n\n<p>Make sure that when making any changes within a submodule, these changes are committed in the main repo to track the submodule&#8217;s current state. Also, remember that changes in a submodule are not automatically pushed with the main project. So, you should go to each submodule and push changes individually.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>A great alternative for git submodule \u2013 git subtree<\/strong><\/h2>\n\n\n\n<p>Imagine your Git repository as a tree. Within this structure, a git subtree serves as a smaller, manageable version of the main tree. Unlike submodules, git subtrees allow you to nest one repository inside another as a subdirectory, offering a more seamless and flexible integration. They can be committed to, branched, and merged just like any other repository. This flexibility makes them an excellent alternative to submodules, particularly when you need to incorporate and manage a project within another.<\/p>\n\n\n\n<p>According to Git\u2019s official documentation, when performing a subtree merge, Git recognizes the relationship between the two projects, allowing for intuitive merging and management. This approach is especially beneficial for projects requiring close integration without the overhead of submodule management.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Why consider git subtree?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It has the same functions as a standard repository.<\/li>\n\n\n\n<li>It&#8217;s easy to use it with your main repository because it&#8217;s saved as commits.<\/li>\n\n\n\n<li>The module&#8217;s contents can be changed without a necessity to create a separate repository copy of the dependency.<\/li>\n\n\n\n<li>Users of your current repository do not need to learn anything new to use the git subtree. They can forget the fact that you&#8217;re managing dependencies with git subtree.<\/li>\n\n\n\n<li>Unlike git submodule, git subtree does not create new metadata files (i.e., .gitmodule).<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/gitprotect.io\/git-commands-cheat-sheet.html?utm_source=blog&amp;utm_medium=blog\" target=\"_blank\" rel=\" noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-1024x1024.png\" alt=\"Git Commands Cheat Sheet\" class=\"wp-image-5077\" style=\"width:450px;height:auto\" srcset=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-1024x1024.png 1024w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-300x300.png 300w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-150x150.png 150w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-768x768.png 768w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-180x180.png 180w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-400x400.png 400w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-600x600.png 600w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands-800x800.png 800w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/git-commands.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-1 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-25\"><a class=\"wp-block-button__link has-white-color has-text-color has-background has-text-align-center wp-element-button\" href=\"https:\/\/gitprotect.io\/git-commands-cheat-sheet.html?utm_source=blog&amp;utm_medium=blog\" style=\"background-color:#ff0300\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Download now<\/strong><\/a><\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">How to use git subtree?<\/h3>\n\n\n\n<p>A subtree can be added to a parent repository. To add a new subtree to a parent repository, you must enter the following commands &#8211;&nbsp; firstly, <em>remote add<\/em> it, secondly, use the <em>subtree add command<\/em>, which looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git remote add remote-name &lt;URL to Git repo&gt;<\/em>\n<em>git subtree add --prefix=folder\/ remote-name &lt;URL to Git repo&gt; subtree-branch name<\/em><\/code><\/pre>\n\n\n\n<p>The commit history of the whole child project gets merged into the parent repository after such commands.<\/p>\n\n\n\n<p>Changes to and from the subtree are pushed and pulled using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>git subtree push-all<\/em>\n<em>git subtree pull-all<\/em><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Best scenarios to use git subtree<\/h3>\n\n\n\n<p>Now, let&#8217;s address some situations where the use of git subtrees is applicable and beneficial. To start off, take a look at managing heavy dependencies (i.e. external tools or libraries) &#8211; git subtree allows you to integrate the entire history of a dependency right into the parent repo. In this case, the user does not need any extra tools or specialized knowledge to be able to work with a dependency and it actually functions just like any other part of the repository. Subtrees can prove useful for projects with complex dependencies that require simple integration into the main codebase. Using subtrees takes away the need for separate <em>.gitmodules<\/em> files, which makes it easier for users to manage.<\/p>\n\n\n\n<p>Another case is the handling of frequent updates. When using subtrees, you can pull and push updates to a dependency as part of the regular commit workflow. This way you can further simplify development processes. How? Well, changes to dependencies and the parent project can be synchronized and therefore, there is no need to manage any external links or metadata files (which often complicates the use of submodules). Subtrees can be rather useful for teams that frequently update libraries or modules.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/gitprotect.io\/devops-backup-academy.html\" target=\"_blank\" rel=\" noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"346\" src=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/banner_orange-1024x346.png\" alt=\"DevOps Backup Academy\" class=\"wp-image-6693\" style=\"width:500px;height:auto\" srcset=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/banner_orange-1024x346.png 1024w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/banner_orange-300x102.png 300w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/banner_orange-768x260.png 768w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/banner_orange-400x135.png 400w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/banner_orange.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Git subtree vs submodule<\/h2>\n\n\n\n<p>As you can see, both options can be used for different things. Now let&#8217;s put these two directly against each other to help you find the right option for your needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Similarities<\/h3>\n\n\n\n<p>External git repositories can be incorporated into other git repositories using git submodule and git subtree. Both techniques allow you to link a specific version of an external component to the local repository and bundle them. Both tools keep tracking the external repository&#8217;s history, enabling you to check out previous commits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>So, git submodule or git subtree?<\/strong><\/h3>\n\n\n\n<p>Submodules have been around for a long time, and have their command (git submodule) and extensive documentation.&nbsp; If we compare it with adding a subtree, adding a submodule is fairly straightforward. All of the hazards and flaws do not appear until the last moment, which can be annoying.<\/p>\n\n\n\n<p>Git submodule is sometimes the best option. This is especially true if your codebase is big and you don&#8217;t want to keep downloading it, as many existing codebases do. Submodules are then used to make it easy for other users, who have no need to download complete blocks of code, to collaborate with you. Because submodule code is the central code used by all container projects, you should aim to keep it independent of other container details.<\/p>\n\n\n\n<p>As for git subtree &#8211; it integrates the external repository&#8217;s history directly into the main project. As a result, you get a unified commit history, unlike the git submodule which keeps separate histories. However, in terms of impact on the main repo&#8217;s size, subtrees add the actual code of the external repository and potentially increase the size. In contrast, the git submodule has minimal impact.<\/p>\n\n\n\n<p>Git subtree also allows updates and integration of changes from external code. This is beneficial for projects that require frequent and two-way integration. Now, this makes them a good pick for managing large and\/or complex repos. Why? Because they streamline the process of adding external changes without the complexity that is typically associated with the git submodule.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Shortcomings of git submodules<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Cloning repositories, which contain submodules, requires downloading the submodules separately. The submodule folders will be empty after cloning if the source repository is moved or becomes unavailable.<\/li>\n\n\n\n<li>This is related to a couple of major disadvantages of Git submodules, including locking to a certain version of an external repository, a lack of good merge management, and the widespread assumption that the Git repository is unaware that it has become a multi-module repository.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Shortcomings of git subtrees<\/h3>\n\n\n\n<p>Among the challenges, it&#8217;s possible to enlist:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A new merging approach must be learned.<\/li>\n\n\n\n<li>It&#8217;s a little more difficult to contribute code for the sub-projects upstream.<\/li>\n\n\n\n<li>You must be sure that super and sub-project code is not mixed in new commits.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p style=\"font-size:22px\">Ensure data protection to your git repositories hosted in <strong>GitHub, GitLab, or Bitbucket and make your source code ransomware-proof and disaster-resistant<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-background wp-element-button\" href=\"https:\/\/gitprotect.io\/sign-up.html\" style=\"border-radius:50px;background-color:#ff0300\" target=\"_blank\" rel=\"noreferrer noopener\">Start 14 days free GitProtect trial<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>Summary<\/p>\n\n\n\n<p>Each tool has advantages and disadvantages. Here are some aspects to consider when you decide which one is ideal for you.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Component-based development favors Git submodules, whereas system-based development favors Git subtrees.<\/li>\n\n\n\n<li>Git submodules have a smaller repository size since they are just links to a single commit in a subproject; whereas Git subtree lets you store the whole subproject, including its history.<\/li>\n\n\n\n<li>Subtrees are decentralized, while Git submodules must be accessible on the server.<\/li>\n<\/ul>\n\n\n\n<p>A Git subtree isn&#8217;t the same thing as a Git submodule. There are certain restrictions on when and how each of them can be used. If you&#8217;re going to upload code to a third-party repository, consider a Git submodule since it&#8217;s faster to do so. Use a Git submodule if you have a third-party code that you won&#8217;t probably push since it is easier to pull.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between Git main module and Git submodule?<\/h3>\n\n\n\n<p>The main module is the primary (parent) repository for a project which contains all the data. In terms of version history, it is managed independently and it tracks its commits along with branches. As for submodules, they are essentially repositories within a parent repository, at a specific path in the parent repository\u2019s working directory.&nbsp;<\/p>\n\n\n\n<p>The main difference between them is the purpose they serve. Using submodules permits cloning another repo into your project while keeping your commits separate.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When should we use Git LFS?<\/h3>\n\n\n\n<p>The usual case when you will need to use the Git LFS extension is to deal with large files when repo history is being transferred to the client during cloning. More precisely, cloning large files that are being modified regularly, since many different versions must be downloaded and that can be time-consuming.<\/p>\n\n\n\n<p>By using Git LFS, you guarantee that these larger files will not be downloaded during cloning or fetching but during the checkout process. This way the effect of such large files on your repo is reduced. That is achieved by replacing the large files with smaller pointer files that can be used to map the locations of files later.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why do we need multiple branches in Git?<\/h3>\n\n\n\n<p>The need for multiple branches in Git derives from project development and related security concerns. The main idea is to have another line of development that is completely isolated from the main master branch. Different branches give the ability to work simultaneously on multiple different modules without affecting the main branch. If your development team works from different remote locations, this could simplify the workflow.&nbsp;<\/p>\n\n\n\n<p>Also, while developing or remaking features or fixing bugs you can do so in different branches and simply merge to your master branch once jobs are finished. Whereas with no branching it is more complicated. If you developed a feature on your main branch, then a second feature on that same branch and you will need to get rid of the first feature, you will have to delete parts of the code and adjust it properly to ensure there are no glitches.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the minimum version of git submodule?&nbsp;<\/h3>\n\n\n\n<p>The minimum version of git that supports submodules is 1.5.3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Before you go:<\/h2>\n\n\n\n<p class=\"has-background\" style=\"background-color:#f4fafe\">\ud83d\udd0e Check out the top reasons <a href=\"https:\/\/gitprotect.io\/sign-up.html?utm_source=blog&amp;utm_medium=blog\" target=\"_blank\" rel=\"noreferrer noopener\">why it\u2019s worth starting to back up DevOps tools<\/a> as soon as possible<br><br>\ud83d\udc19 Do you think that if you use GitHub\/GitLab\/Bitbucket, you don\u2019t need a backup? We\u2019ve busted this myth in our <a href=\"https:\/\/gitprotect.io\/blog\/i-use-github-gitlab-bitbucket-so-i-dont-need-backup\/\" target=\"_blank\" rel=\"noreferrer noopener\">DevSecOps MythBuster<\/a> blog post! Check it out!<br><br>\ud83d\udcda Don\u2019t miss our series of articles where we\u2019ve investigated 2023 for threats: <a href=\"https:\/\/gitprotect.io\/blog\/atlassian-security-incidents-2023-in-review\/\" target=\"_blank\" rel=\"noreferrer noopener\">Atlassian security incidents<\/a>, <a href=\"https:\/\/gitprotect.io\/blog\/2023-in-review-infamous-github-related-incidents-and-threats\/\" target=\"_blank\" rel=\"noreferrer noopener\">infamous GitHub-related incidents<\/a>, and <a href=\"https:\/\/gitprotect.io\/blog\/gitlab-vulnerabilities-and-security-incidents-2023-in-review\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitLab vulnerabilities and security incidents<\/a><br><br>\ud83d\udc40 Read our comprehensive analysis, <a href=\"https:\/\/gitprotect.io\/blog\/your-own-git-backup-script-vs-repository-backup-software\/\" target=\"_blank\" rel=\"noreferrer noopener\">Your own Git backup script vs. repository backup software<\/a>, and see which option better meets your requirements<br><br>\u270d\ufe0f Subscribe to <a href=\"https:\/\/gitprotect.io\/sign-up.html?utm_source=blog&amp;utm_medium=blog\" target=\"_blank\" rel=\"noreferrer noopener\">GitProtect DevSecOps X-Ray Newsletter<\/a> and always stay up-to-date with the latest DevSecOps insights<br><br>\ud83d\udcc5 Schedule <a href=\"https:\/\/calendly.com\/d\/3s9-n9z-pgc\/gitprotect-live-demo?month=2024-03\" target=\"_blank\" rel=\"noreferrer noopener\">a live custom demo<\/a> and learn more about GitProtect backups for your DevOps data protection<br><br>\ud83d\udccc Or try <a href=\"https:\/\/calendly.com\/d\/3s9-n9z-pgc\/gitprotect-live-demo?month=2024-03\" target=\"_blank\" rel=\"noreferrer noopener\">GitProtect backups for your GitLab, Bitbucket, GitHub, or Jira ecosystem<\/a> to guarantee data protection and ensure continuous workflow<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While working on a project, it&#8217;s common to have it combined with another one, especially if you work in a network with other people. It might be a library built by other developers, or a piece of the project developed independently and then reused in several projects. When such a thing happens, you want to keep both projects distinct yet you want to be able to use one of them in a different one. This post was written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":2738,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2722","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git-backup-101","post--single"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Managing Git Projects: Git Subtree vs. Submodule - Blog | GitProtect.io<\/title>\n<meta name=\"description\" content=\"What are sug subtree and submodule and how to use them? This post was been written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Managing Git Projects: Git Subtree vs. Submodule - Blog | GitProtect.io\" \/>\n<meta property=\"og:description\" content=\"What are sug subtree and submodule and how to use them? This post was been written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog | GitProtect.io\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/XoperoSoftware\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-21T14:33:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-13T07:43:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jakub Grodecki\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GitProtectio\" \/>\n<meta name=\"twitter:site\" content=\"@GitProtectio\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jakub Grodecki\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\"},\"author\":{\"name\":\"Jakub Grodecki\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/3cfd86c630bf938b35bdcf961774f7ea\"},\"headline\":\"Managing Git Projects: Git Subtree vs. Submodule\",\"datePublished\":\"2022-04-21T14:33:10+00:00\",\"dateModified\":\"2025-06-13T07:43:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\"},\"wordCount\":2185,\"publisher\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png\",\"articleSection\":[\"Git Backup 101\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\",\"name\":\"Managing Git Projects: Git Subtree vs. Submodule - Blog | GitProtect.io\",\"isPartOf\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png\",\"datePublished\":\"2022-04-21T14:33:10+00:00\",\"dateModified\":\"2025-06-13T07:43:23+00:00\",\"description\":\"What are sug subtree and submodule and how to use them? This post was been written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best.\",\"breadcrumb\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png\",\"width\":1200,\"height\":600,\"caption\":\"git subtree\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Strona g\u0142\u00f3wna\",\"item\":\"https:\/\/gitprotect.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Managing Git Projects: Git Subtree vs. Submodule\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#website\",\"url\":\"https:\/\/gitprotect.io\/blog\/\",\"name\":\"GitProtect.io Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/gitprotect.io\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\",\"name\":\"GitProtect.io\",\"url\":\"https:\/\/gitprotect.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png\",\"width\":528,\"height\":528,\"caption\":\"GitProtect.io\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/XoperoSoftware\/\",\"https:\/\/x.com\/GitProtectio\",\"https:\/\/www.linkedin.com\/company\/xopero-software\/\",\"https:\/\/www.youtube.com\/channel\/UCiEnl6n0mIO6w7twccz-l2w\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/3cfd86c630bf938b35bdcf961774f7ea\",\"name\":\"Jakub Grodecki\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dda6823ae9f9675de9be49d8359f2778?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dda6823ae9f9675de9be49d8359f2778?s=96&d=mm&r=g\",\"caption\":\"Jakub Grodecki\"},\"url\":\"https:\/\/gitprotect.io\/blog\/author\/jakub-grodecki\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Managing Git Projects: Git Subtree vs. Submodule - Blog | GitProtect.io","description":"What are sug subtree and submodule and how to use them? This post was been written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/","og_locale":"en_US","og_type":"article","og_title":"Managing Git Projects: Git Subtree vs. Submodule - Blog | GitProtect.io","og_description":"What are sug subtree and submodule and how to use them? This post was been written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best.","og_url":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/","og_site_name":"Blog | GitProtect.io","article_publisher":"https:\/\/www.facebook.com\/XoperoSoftware\/","article_published_time":"2022-04-21T14:33:10+00:00","article_modified_time":"2025-06-13T07:43:23+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png","type":"image\/png"}],"author":"Jakub Grodecki","twitter_card":"summary_large_image","twitter_creator":"@GitProtectio","twitter_site":"@GitProtectio","twitter_misc":{"Written by":"Jakub Grodecki","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#article","isPartOf":{"@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/"},"author":{"name":"Jakub Grodecki","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/3cfd86c630bf938b35bdcf961774f7ea"},"headline":"Managing Git Projects: Git Subtree vs. Submodule","datePublished":"2022-04-21T14:33:10+00:00","dateModified":"2025-06-13T07:43:23+00:00","mainEntityOfPage":{"@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/"},"wordCount":2185,"publisher":{"@id":"https:\/\/gitprotect.io\/blog\/#organization"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage"},"thumbnailUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png","articleSection":["Git Backup 101"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/","url":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/","name":"Managing Git Projects: Git Subtree vs. Submodule - Blog | GitProtect.io","isPartOf":{"@id":"https:\/\/gitprotect.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage"},"thumbnailUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png","datePublished":"2022-04-21T14:33:10+00:00","dateModified":"2025-06-13T07:43:23+00:00","description":"What are sug subtree and submodule and how to use them? This post was been written to assist you in managing projects using Git subtree and submodule. We will show you the key differences, so you can decide which choice is the best.","breadcrumb":{"@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#primaryimage","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/04\/blog-git.png","width":1200,"height":600,"caption":"git subtree"},{"@type":"BreadcrumbList","@id":"https:\/\/gitprotect.io\/blog\/managing-git-projects-git-subtree-vs-submodule\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Strona g\u0142\u00f3wna","item":"https:\/\/gitprotect.io\/blog\/"},{"@type":"ListItem","position":2,"name":"Managing Git Projects: Git Subtree vs. Submodule"}]},{"@type":"WebSite","@id":"https:\/\/gitprotect.io\/blog\/#website","url":"https:\/\/gitprotect.io\/blog\/","name":"GitProtect.io Blog","description":"","publisher":{"@id":"https:\/\/gitprotect.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gitprotect.io\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/gitprotect.io\/blog\/#organization","name":"GitProtect.io","url":"https:\/\/gitprotect.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png","width":528,"height":528,"caption":"GitProtect.io"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/XoperoSoftware\/","https:\/\/x.com\/GitProtectio","https:\/\/www.linkedin.com\/company\/xopero-software\/","https:\/\/www.youtube.com\/channel\/UCiEnl6n0mIO6w7twccz-l2w"]},{"@type":"Person","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/3cfd86c630bf938b35bdcf961774f7ea","name":"Jakub Grodecki","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dda6823ae9f9675de9be49d8359f2778?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dda6823ae9f9675de9be49d8359f2778?s=96&d=mm&r=g","caption":"Jakub Grodecki"},"url":"https:\/\/gitprotect.io\/blog\/author\/jakub-grodecki\/"}]}},"_links":{"self":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/2722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/comments?post=2722"}],"version-history":[{"count":8,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/2722\/revisions"}],"predecessor-version":[{"id":6697,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/2722\/revisions\/6697"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/media\/2738"}],"wp:attachment":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/media?parent=2722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/categories?post=2722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/tags?post=2722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}