git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to checkout a revision that contains a deleted submodule?

From
Luke Diamand <luke@diamand.org>
Date
Sep 19, 2020, 09:03 UTC
Message-ID
<CAE5ih78zCR0ZdHAjoxguUb3Y6KFkZcoxJjhS7rkbtZpr+d1n=g@mail.gmail.com>
Maybe this is a FAQ, but I couldn't figure it out!
I have a repo which has a couple of submodules.
At some point in the past I deleted one of those submodules:
    git rm sub2
    git add -u
    git commit -m 'Deleting sub2'
    git push origin
    ...
    ... more commits and pushes...
Now I go and clone the head revision. This gives me a clone which has
nothing present in .git/modules/sub2.
    login on some other machine
    git clone git@my.repo:thing
    cd thing
    ls .git/modules
    <sub2 not present>
So when I go and checkout an old revision where sub2 is still around I get:
    git checkout oldrevision
    fatal: not a git repository: sub2/../.git/modules/sub2

What am I doing wrong? What set of commands do I need to use to ensure that this will always do the right thing?

Thanks Luke

Next: Luke Diamand
Message 1 of 7 in “How to checkout a revision that contains a deleted submodule?”
  1. Luke DiamandSep 19, 2020
  2. Luke DiamandSep 20, 2020
  3. Kaartic SivaraamSep 20, 2020
  4. Luke DiamandSep 20, 2020
  5. Philippe BlainSep 21, 2020
  6. Luke DiamandSep 22, 2020
  7. Philippe BlainSep 21, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.