<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Submodules on Nerdsid.com</title><link>https://nerdsid.com/tags/submodules/</link><description>Recent content in Submodules on Nerdsid.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 01 Jan 2025 05:20:44 +0000</lastBuildDate><atom:link href="https://nerdsid.com/tags/submodules/index.xml" rel="self" type="application/rss+xml"/><item><title>How to Clone a Git Repository Along With Its Submodules</title><link>https://nerdsid.com/posts/how-to-clone-a-git-repository-along-with-its-submodules/</link><pubDate>Wed, 01 Jan 2025 05:20:44 +0000</pubDate><guid>https://nerdsid.com/posts/how-to-clone-a-git-repository-along-with-its-submodules/</guid><description>&lt;p>When you clone a Git repository with submodule(s) in it, by default you get the directories that contain submodule(s), but none of the files within them.&lt;/p>
&lt;h2 id="clone-with-submodules-in-one-command">Clone with Submodules in One Command&lt;/h2>
&lt;p>If you pass &lt;code>--recurse-submodules&lt;/code> option to the git clone command, it automatically initializes and updates all submodules in the repository, including nested ones if they exist.&lt;/p>






&lt;div class="codeblock">
 &lt;div class="codeblock__header">
 &lt;div class="codeblock__filename codeblock__filename--lang">
 
 BASH
 
 &lt;/div>
 &lt;div class="codeblock__actions">
 
 &lt;/div>
 &lt;/div>
 &lt;div class="codeblock__body">
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git clone --recurse-submodules &amp;lt;repository_url&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;p>For example:&lt;/p>






&lt;div class="codeblock">
 &lt;div class="codeblock__header">
 &lt;div class="codeblock__filename codeblock__filename--lang">
 
 BASH
 
 &lt;/div>
 &lt;div class="codeblock__actions">
 
 &lt;/div>
 &lt;/div>
 &lt;div class="codeblock__body">
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git clone --recurse-submodules https://github.com/example/repo.git&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;h2 id="another-way-to-initialize-and-update-submodules">Another Way to Initialize and Update Submodules&lt;/h2>
&lt;p>If you&amp;rsquo;ve already cloned a repository but forgot to use &lt;code>--recurse-submodules&lt;/code>, you can run &lt;code>git submodule update --init&lt;/code> to initialize and update the submodules. To make sure all submodules, including nested ones, are initialized, fetched, and checked out, use &lt;code>git submodule update --init --recursive&lt;/code>.&lt;/p></description></item><item><title>Update Git Submodule to the Latest Commit</title><link>https://nerdsid.com/posts/update-git-submodule-to-the-latest-commit/</link><pubDate>Thu, 26 Sep 2024 15:39:06 +0530</pubDate><guid>https://nerdsid.com/posts/update-git-submodule-to-the-latest-commit/</guid><description>&lt;p>When working with Git submodules, it&amp;rsquo;s common to update them to incorporate changes from their upstream repositories. To do this you can run the following command:&lt;/p>






&lt;div class="codeblock">
 &lt;div class="codeblock__header">
 &lt;div class="codeblock__filename codeblock__filename--lang">
 
 BASH
 
 &lt;/div>
 &lt;div class="codeblock__actions">
 
 &lt;/div>
 &lt;/div>
 &lt;div class="codeblock__body">
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git submodule update --remote --merge&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;p>This process, in Git&amp;rsquo;s parlance, is known as &lt;em>updating and merging submodules&lt;/em>. It ensures that your submodules are synchronized with the latest changes from their upstream repositories.&lt;/p>

 &lt;link rel="stylesheet" href="https://nerdsid.com/css/vendors/admonitions.a8c7c1ccf86e56de6a22b2b6efa296023e0063d5295f3600da793b7fe6cea5f8.css" integrity="sha256-qMfBzPhuVt5qIrK276KWAj4AY9UpXzYA2nk7f&amp;#43;bOpfg=" crossorigin="anonymous">
 &lt;div class="admonition important">
 &lt;div class="admonition-header">
 &lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">&lt;path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"/>&lt;/svg>
 &lt;span>Important&lt;/span>
 &lt;/div>
 &lt;div class="admonition-content">
 &lt;p>After updating and merging the submodule, don&amp;rsquo;t forget to commit the change in your main repository. This ensures the new submodule state is recorded and shared with others working on the project. Here&amp;rsquo;s how to do that:&lt;/p></description></item></channel></rss>