0

I cloned a under my current project and git shows it as a submodule, which I want to remove.

I can't follow answers like this one to remove the submodule since there is no .git/modules.

So I did rm -rf a/.git. But then any git action to my current project like git status throws error fatal: 'a/.git' not recognized as a git repository.

How can I solve this error? Or how can I remove the submodule properly?

Here's a log of ls -l .git and cat .git/config under my current project. I can't see anything named after "modules".

total 64
-rw-r--r--   1 jeffreyyu  staff    13 Apr 17 10:50 COMMIT_EDITMSG
-rw-r--r--@  1 jeffreyyu  staff    93 Apr 21 07:46 FETCH_HEAD
-rw-r--r--   1 jeffreyyu  staff    23 Apr 16 13:28 HEAD
-rw-r--r--   1 jeffreyyu  staff    41 Apr 21 07:35 ORIG_HEAD
-rw-r--r--@  1 jeffreyyu  staff   309 Apr 17 08:07 config
-rw-r--r--   1 jeffreyyu  staff    73 Apr 16 13:28 description
drwxr-xr-x@ 15 jeffreyyu  staff   480 Apr 19 02:36 hooks
-rw-r--r--   1 jeffreyyu  staff  1520 Apr 21 07:35 index
drwxr-xr-x@  3 jeffreyyu  staff    96 Apr 19 02:36 info
drwxr-xr-x@  4 jeffreyyu  staff   128 Apr 19 02:36 logs
drwxr-xr-x@ 49 jeffreyyu  staff  1568 Apr 21 07:46 objects
-rw-r--r--   1 jeffreyyu  staff   114 Apr 16 13:28 packed-refs
drwxr-xr-x@  5 jeffreyyu  staff   160 Apr 19 02:36 refs
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = git@github.com:JeffreytheCoder/cura.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
  • If you have not added and committed `a`, you don't have a submodule yet and you're fine. If you *did* add and commit but did not use `git submodule add`, you have what I like to call a "half-assed" submodule, and you're not fine: the commits that have this half-assed submodule are not really usable and probably should be discarded if possible (though whether it's possible depends on a lot of other things). – torek Apr 21 '22 at 15:52
  • In any case, since you *don't* have the `.git/modules`, that tells me that you never ran `git submodule absorbgitdirs` (which if you *did* want a submodule, you would have done after the `git submodule add` step, but since you don't want one, it's just as well that you didn't). So you have less to do than is shown in that answer. – torek Apr 21 '22 at 15:53

0 Answers0