<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git on Nerdsid.com</title><link>https://nerdsid.com/tags/git/</link><description>Recent content in Git on Nerdsid.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 26 Oct 2025 14:54:48 +0530</lastBuildDate><atom:link href="https://nerdsid.com/tags/git/index.xml" rel="self" type="application/rss+xml"/><item><title>Why git add Wildcard Won’t Stage Your Nested Files (And How to Fix It)</title><link>https://nerdsid.com/posts/why-git-add-wildcard-wont-stage-nested-files/</link><pubDate>Sun, 26 Oct 2025 14:54:48 +0530</pubDate><guid>https://nerdsid.com/posts/why-git-add-wildcard-wont-stage-nested-files/</guid><description>&lt;p>I recently ran into an issue while working with Git. I had a bunch of Markdown files spread across multiple nested folders and wanted to stage them all at once. So I ran:&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 add *.md&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;p>But only the &lt;code>.md&lt;/code> files in the current directory got added (to the staging area). The &lt;code>.md&lt;/code> files in the nested directories didn&amp;rsquo;t get added.&lt;/p>
&lt;p>The root casue: the &lt;code>*&lt;/code> wildcard isn’t processed by Git, but by the shell. So the shell was only matching them in the current folder. What a revelation!&lt;/p></description></item><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>Git terms explained in simple words</title><link>https://nerdsid.com/posts/git-terms-explained-in-simple-words/</link><pubDate>Wed, 11 Dec 2024 07:32:28 +0530</pubDate><guid>https://nerdsid.com/posts/git-terms-explained-in-simple-words/</guid><description>&lt;h3 id="branches">Branches&lt;/h3>
&lt;p>Branches are copies of the main project where you can make changes without affecting the production project until you&amp;rsquo;re ready to integrate the changes. They allow developers to work on new features, bug fixes, or experiment in isolation. When the changes are complete and reviewed, you merge the branch back into the main project.&lt;/p>
&lt;p>Examples:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Feature branches&lt;/strong>: Used for developing new features. For example, if you&amp;rsquo;re adding a login page to a website, you would create a feature branch like &lt;code>feature/login-page&lt;/code> to make all the necessary changes.&lt;/li>
&lt;li>&lt;strong>Bugfix branches&lt;/strong>: Created to fix specific bugs. For instance, if there&amp;rsquo;s an issue with the checkout process, a branch like &lt;code>bugfix/checkout-error&lt;/code> could be used.&lt;/li>
&lt;li>&lt;strong>Release branches&lt;/strong>: Prepared when you&amp;rsquo;re close to releasing a version of the project. A release branch might be named &lt;code>release/v1.0&lt;/code> to finalize new features before they go live.&lt;/li>
&lt;li>&lt;strong>Hotfix branches&lt;/strong>: These are for urgent fixes that need to be addressed in production immediately. An example could be &lt;code>hotfix/critical-bug&lt;/code> to address a security vulnerability found after release.&lt;/li>
&lt;/ul>
&lt;h3 id="commit">Commit&lt;/h3>
&lt;p>A commit is a snapshot of the changes made to files in a branch. It records the specific modifications made at a particular point in time, so that developers can track the history of changes and revert to previous versions if necessary. A commit typically includes a message describing what was changed.&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><item><title>How to Set Git Username and Email Using Environment Variables</title><link>https://nerdsid.com/posts/git-username-and-email-from-environment-variables/</link><pubDate>Wed, 11 Sep 2024 15:39:06 +0530</pubDate><guid>https://nerdsid.com/posts/git-username-and-email-from-environment-variables/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>Git associates a username and email with every commit. The username and email are retrieved from Git&amp;rsquo;s configuration, which can be set globally (for all repositories) or locally (for a specific repository). For example to set the username globally, you can run the command &lt;code>git config --global user.name &amp;quot;Your Name&amp;quot;&lt;/code>.&lt;/p>
&lt;p>However, an alternative way to achieve this is by using environment variables. This can be useful for several reasons, such as:&lt;/p></description></item><item><title>Edit Last Commit Message in Git</title><link>https://nerdsid.com/posts/git-edit-last-commit-message/</link><pubDate>Wed, 13 Sep 2023 15:39:06 +0530</pubDate><guid>https://nerdsid.com/posts/git-edit-last-commit-message/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>Picture this: you&amp;rsquo;re on a coding spree, rushing to fulfill a project deadline. You&amp;rsquo;ve just committed your changes to Git. All of a sudden, you notice a typo in your last commit message! But don&amp;rsquo;t worry, you have the ability to correct it in the realm of Git.&lt;/p>
&lt;h2 id="modify-the-last-commit-message">Modify the last commit message&lt;/h2>
&lt;p>To update the last commit message in Git, you can use the &lt;code>--amend&lt;/code> option with the &lt;code>git commit&lt;/code> command. The following command illustrates it.&lt;/p></description></item><item><title>How to Fix Common Git Mistakes</title><link>https://nerdsid.com/posts/avoiding-disaster-how-to-fix-common-git-mistakes-like-a-pro/</link><pubDate>Wed, 03 May 2023 05:27:57 +0000</pubDate><guid>https://nerdsid.com/posts/avoiding-disaster-how-to-fix-common-git-mistakes-like-a-pro/</guid><description>&lt;p>Git is a version control system that allows developers to manage and track changes to their codebase over time. It is easy to make mistakes, while working with Git. This can result in confusion, lost effort, and even data loss. In this post, we&amp;rsquo;ll go over some common Git problems and their solutions. Whether you&amp;rsquo;re new to Git or want to enhance your Git skills, these tips will help you become a more efficient and productive developer.&lt;/p></description></item><item><title>View Files Changed in Git Commits</title><link>https://nerdsid.com/posts/view-details-of-files-in-git-commits/</link><pubDate>Thu, 16 Mar 2023 00:00:00 +0530</pubDate><guid>https://nerdsid.com/posts/view-details-of-files-in-git-commits/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>I recently got into a situation, where changes made to a file was committed, but I was not sure which commit captured those changes. So, I wanted to know the files changed in past commits. One of the easiest way to do this is to simply check the history of your repo on GitHub or GitLab etc. But I didn&amp;rsquo;t push my local commits, since I wanted to ensure that things are perfect before I push. I found the following commands to be useful in this regard.&lt;/p></description></item><item><title>Setup SSH Authentication for Git on Windows</title><link>https://nerdsid.com/posts/setup-ssh-authentication-for-git-in-windows/</link><pubDate>Mon, 13 Mar 2023 00:00:00 -0800</pubDate><guid>https://nerdsid.com/posts/setup-ssh-authentication-for-git-in-windows/</guid><description>&lt;h2 id="ssh-auth-vs-password-based-auth">SSH auth vs password based auth&lt;/h2>
&lt;p>SSH authentication is generally preferred over password-based authentication for several reasons:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Security&lt;/strong>: Passwords are easily guessed or hacked, whereas SSH authentication relies on cryptographic keys, which are much more difficult to crack.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Convenience&lt;/strong>: Once you&amp;rsquo;ve configured SSH authentication, logging in to a remote system becomes much easier. You don&amp;rsquo;t need to remember or type in a password every time you log in; instead, you just need to have your SSH key handy.&lt;/p></description></item><item><title>How to Exclude Files When Using git add</title><link>https://nerdsid.com/posts/optimizing-your-git-workflow-excluding-files-during-git-add/</link><pubDate>Tue, 22 Nov 2022 23:33:25 +0530</pubDate><guid>https://nerdsid.com/posts/optimizing-your-git-workflow-excluding-files-during-git-add/</guid><description>&lt;h2 id="problem">Problem&lt;/h2>
&lt;p>Sometimes you want to add all files to git except some files or folders.&lt;/p>
&lt;h2 id="solution">Solution&lt;/h2>
&lt;p>You can use the &lt;code>:(exclude)&lt;/code> syntax to exclude files or folders from the &lt;code>git add&lt;/code> command. The &lt;code>:(exclude)&lt;/code> pathspec modifier is a special syntax that allows you to exclude files or folders. A pathspec is a way to specify files in Git. It is a string that describes a set of files. You can use wildcards to match multiple files. For example, &lt;code>*.html&lt;/code> matches all html files. &lt;code>**/*.html&lt;/code> matches all html files in all subfolders.&lt;/p></description></item><item><title>How to Delete Git Local and Remote Tags</title><link>https://nerdsid.com/posts/how-to-delete-git-local-and-remote-tags/</link><pubDate>Fri, 28 Oct 2022 07:32:28 +0530</pubDate><guid>https://nerdsid.com/posts/how-to-delete-git-local-and-remote-tags/</guid><description>&lt;p>You can safely delete a git tag if you created one unintentionally.&lt;/p>
&lt;h2 id="delete-git-tag-from-local-repository">Delete git tag from local repository&lt;/h2>
&lt;p>Use the &lt;code>git tag&lt;/code> command with the &amp;ldquo;-d&amp;rdquo; option to remove a tag from the local repository.&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 tag -d &amp;lt;tag_name&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;p>Let&amp;rsquo;s say you want to delete tag &lt;code>v1.2.3&lt;/code>, then the following command can be used.&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 tag -d v1.2.3&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;p>After executing this command, you should see a similar output as below.&lt;/p></description></item><item><title>How to Edit Multiple Git Commit Messages</title><link>https://nerdsid.com/posts/git-edit-multiple-commit-messages/</link><pubDate>Fri, 16 Sep 2022 00:00:00 +0530</pubDate><guid>https://nerdsid.com/posts/git-edit-multiple-commit-messages/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>I recently got into a situation, where I had to edit multiple git commit messages. I was contributing to a project and had already added my commits. But, I had to change the commit messages to follow the project&amp;rsquo;s commit message guidelines.&lt;/p>
&lt;h2 id="using-git-rebase-to-edit-commit-history">Using git rebase to edit commit history&lt;/h2>
&lt;p>&lt;code>git rebase&lt;/code> is a powerful command that can be used to edit commit history. It can be used to edit commit messages, squash commits, reorder commits, and much more.&lt;/p></description></item><item><title>How to undo a Git Commit in Your Local and Remote Repository</title><link>https://nerdsid.com/posts/undo-a-git-commit-locally-and-remotely/</link><pubDate>Tue, 13 Sep 2022 17:54:30 +0530</pubDate><guid>https://nerdsid.com/posts/undo-a-git-commit-locally-and-remotely/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>It is very common to make mistakes while working on a project. Sometimes, you may have made a commit with the wrong changes. In such cases, you may want to undo the commit and make a new commit with the correct changes. In this post, we will see how to undo a commit in your local and remote repositories.&lt;/p>
&lt;h2 id="undo-a-commit-in-your-local-repository">Undo a commit in your local repository&lt;/h2>
&lt;p>The word &amp;lsquo;undo&amp;rsquo; here means that:&lt;/p></description></item></channel></rss>