Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

Can Git Submodules Track Tags? Pin a Release Commit Instead

Git submodules pin commits, not tags. To use a tagged release, check out its commit inside the submodule and commit the changed gitlink in the superproject.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Git submodules do not track a tag through .gitmodules. To use a release tag, check out that tag inside the submodule, then commit the resulting submodule commit reference—the gitlink—in the parent repository. That pins a specific commit for collaborators. If you want updates from a moving upstream branch instead, configure branch tracking and use git submodule update --remote.

What “tracking a tag” means for a submodule

A submodule has two related but distinct pieces of state: the submodule repository’s own checkout, and the commit that the superproject records for that submodule path. The superproject records a gitlink to a specific commit. That commit—not a tag name or a branch name—is the dependency pin that collaborators receive.

As an Amazon Associate I earn from qualifying purchases.

The submodule.<name>.branch setting in .gitmodules names a remote branch for tracking updates. It is not a documented tag-following setting. Likewise, git submodule update --remote updates from a remote-tracking branch; ordinary git submodule update checks out the commit recorded by the superproject. See the Git documentation for .gitmodules, git submodule, and gitlinks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to pin a submodule to a release tag

  1. Initialize the submodule if it has not been initialized, then fetch its tags:

    git submodule update --init path/to/submodule
    git -C path/to/submodule fetch --tags
  2. Check out the desired tag in the submodule. A detached checkout is normal here:

    git -C path/to/submodule checkout --detach v1.2.3
  3. From the superproject, stage the submodule path and commit the updated gitlink:

    git add path/to/submodule
    git commit -m "Pin submodule to v1.2.3"
  4. Have collaborators update their checkout from the superproject’s recorded commit:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    git submodule update --init --recursive

The tag is a convenient way for you to select the release commit. The committed gitlink records the selected commit ID, so collaborators do not need to resolve the tag themselves.

When to use a tag-selected commit or a branch

Approach How it updates Best suited to
Choose a commit through a tag, then commit the gitlink The superproject stays pinned to the selected commit until you change and commit the gitlink. Repeatable builds, deliberate release upgrades, and review before adopting a dependency change.
Track a remote branch with submodule.<name>.branch and run git submodule update --remote The submodule can move to a newer commit as the remote branch advances; commit the resulting gitlink change in the superproject to record the update. Intentionally adopting ongoing upstream branch changes.

For branch tracking, set submodule.<name>.branch to the remote branch name in .gitmodules. The exact submodule name is the section name used by that file; it may differ from the path. The Git documentation defines this setting as “A remote branch name for tracking updates in the upstream submodule.”

What happens if the tag moves or disappears?

The superproject still records the commit ID it selected, even if the tag is later moved or deleted. But reproducibility also depends on being able to obtain that commit: the submodule remote must continue to retain and serve it. A tag helps identify the intended release for maintainers; it does not replace the commit reference stored in the superproject.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What collaborators should run

After the superproject change is committed and shared, collaborators can run git submodule update --init --recursive to initialize and check out the recorded commits, including nested submodules. For one submodule, use a path-specific form such as git submodule update --init path/to/submodule. Git checks out the recorded commit in the submodule on a detached HEAD; that is expected. To make a different tag-selected release the project’s dependency, the maintainer must update the submodule checkout and commit the changed gitlink in the superproject.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.