Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:35:18+00:00 2026-06-10T07:35:18+00:00

The .gitmodule file only specifies the module repository url. How does git submodule know

  • 0

The .gitmodule file only specifies the module repository url. How does git submodule know which version to download? It seems to be always checking out the latest version. Then, how does developers ensure compatibility between the main project and the sub modules?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:35:20+00:00Added an answer on June 10, 2026 at 7:35 am

    Your submodule is represented as a special entry with a special mode (called a gitlink, see “Nested git repositories without submodules?“):
    (See “Checkout past git submodule commit“)

    new file mode 160000
    index 0000000..4c4c5a2
    

    So it isn’t checking out the “LATEST” version, but always a specific SHA1, and it does so in a DETACHED HEAD mode (see “How to make submodule with detached HEAD to be attached to actual HEAD?“.

    That doesn’t mean you can’t update a submodule, as I explain in “true nature of submodules“.

    For more on submodules, and on potentially why you might not want to use them(!), read the sobering article “Why your company shouldn’t use Git submodules“, from Amber Yust (also on SO).

    Just one small extract, for kicks and giggles (emphasis mine):

    When you invoke git submodule update it looks in the parent repository for a SHA for each submodule, goes into those submodules, and checks out the corresponding SHAs.
    As would be the case if you checked out a SHA in a regular repository, this puts the submodule into a detached HEAD state.

    If you then make changes in the submodule and commit then, Git will happily create the commit… and leave you still with a detached HEAD. See where this is going yet?

    Say you merge in some more changes which happen to include another submodule update. If you haven’t committed your own submodule change into the parent project yet, Git won’t consider your new commit in the submodule as a conflict, and if you run git submodule update it will happily wipe out your commit without warning, replacing it with that from the branch you just merged in.

    I hope you had your submodule’s reflog enabled or still have the old commit in your terminal scrollback, because otherwise, you just lost all that work you did.

    Err… “ouch”.


    Note that now a submodule can track the latest from a branch: see “git submodule tracking latest“.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the .gitmodule file have the list of submodule url and path, similar to this
I add a submodule from a git@... URL, to be able to develop in
I have a project that has a submodule at lib/three20 My .gitmodule file looks
I have a gitmodules file like this: [submodule dotfiles/vim/bundle/cucumber] path = dotfiles/vim/bundle/cucumber url =
I added a submodule: git submodule add git://github.com/chneukirchen/rack.git rack A file .gitmodules was created
I have a git repository set up with several submodules, which creates a .gitmodules
I'm trying to use git submodule update and it's not returning anything, nor does
I'm referencing a git submodule in my project, and now need to reference a
If I add a submodule that does not currently exist, no submodule information is
I would like to change the directory name of a Git submodule in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.