I noticed gitlens doesn't work for submodules. When you have a project and inside it you have one or more submodules, gitlens completely ignore them.
Do you plan to implement this functionality by chance?
I've never used submodules myself, so I'm not familiar with them. I did a bunch of work a while back to support sub-repos (and I think that still works, though I believe I noticed a bug the other day). When you say that it just ignores them, what does that mean exactly? You could also try turning on the output logging via "gitlens.output.level": "verbose" setting and see if there are any error messages there.
There isn't any error message coming. Only a warning like this:
"Unable to show commit details. File is probably not under source control" when I, for example, try to use "Show commit details" on a file that is under the submodule.
When I say that gitlens ignores it I mean that the extension doesn't work at all on a file versioned by a submodule.
That warning should generate a much better message in the GitLens output channel if you turn set "gitlens.output.level": "verbose". Can you turn that on, and retry? Then post the logs here?
@eamodio I did this configuration then under the output tab nothing is shown. Is the any other thing I could do?
Sorry I gave you the wrong setting, its "gitlens.advanced.output.level": "verbose" -- that's what I get for not looking it up first.
Now we go! =)
This happens when, for example, I open a file tfsa-directives.js which is under the submodule.
CodeLens config changed; resetting CodeLens provider
Triggering a reset of the git CodeLens provider
getBlameForFile('/data/dev/wpd', '/data/dev/wpd/src/main/resources/templates/phn/html/js/dashboard/accounts/tfsa-directives.js', undefined)
Add blame cache for '/data/dev/wpd/src/main/resources/templates/phn/html/js/dashboard/accounts/tfsa-directives.js'
git blame --root --incremental -- src/main/resources/templates/phn/html/js/dashboard/accounts/tfsa-directives.js cwd='/data/dev/wpd'
Error: fatal: no such path 'src/main/resources/templates/phn/html/js/dashboard/accounts/tfsa-directives.js' in HEAD Failed with exit code: 128
getBlameForFile('/data/dev/wpd', '/data/dev/wpd/src/main/resources/templates/phn/html/js/dashboard/accounts/tfsa-directives.js', undefined)
getBlameForFile('/data/dev/wpd', '/data/dev/wpd/src/main/resources/templates/phn/html/js/dashboard/accounts/tfsa-directives.js', undefined)
@thiagoh thanks for the output -- I think I broke this in one of the more recent updates :(
I'll look into fixing it
Thank you @eamodio
Tell me if you need some help with that..
@thiagoh do you happen to have a repo that has a submodule that I can clone to test with?
@eamodio, unfortunately the repo with submodules I use is private. However, if you could create one repo with submodules to test you'll see that is quite simple:
Take these examples:
@thiagoh could you try a test with this: gitlens-3.1.1.zip
To install it first rename it to gitlens-3.1.1.vsix, then make sure to uninstall the current version of GitLens from vs code (and reload), then use the Install from VSIX... menu choice from the ... extensions menu.
@eamodio I'm sorry for the delay..
Look, when I tried to install from the .vsix file I got the following error
end of central directory record signature not found
@thiagoh Not sure what happened there -- very odd. But I've just published v3.2.0 to the marketplace -- please try that out and let me know if it works for you. Thanks!
@eamodio working perfectly! thank you so much!
@thiagoh excellent news! Closing this out then :)
Hey @thiagoh, how are you seeing the submodules?
I don't see my submodule, I just see this:

These don't work for me either. I think you should reopen the issue.
@vladipus Can you provide more details to the structure of your project (hierarchy of where the git repo is and the submodules)? Or if its an open source repo, point me to it?
I'm having the same problem. I have created an example repository with 3 submodules, similar to my setup. If you navigate to history of the master branch from gitlens explorer view, you can see changes for files that are local to the repo, but if you pulled new changes for submodules and commit the submodule updates, you can not see the changes for those files under the submodules. VSCode gives the error "Unable to open compare. See output channel for more details", which says
> git rev-parse --show-toplevel
fatal: not a git repository (or any of the parent directories): .git
Bump,
Git submodules are super common these days.
Is anyone working on this right now?
@andygikling Have you tried with GitLens 9? And if so, can you detail what isn't working that you expect to be working? Thanks!
First of all I love what Gitlens is all about. I looked closer at it. There are two main problems.
The first issue is yes it shows submodules but it doesn't recuse the folder tree looking for more. It only shoes submodules for git directories directly below the current VS code active folder. Maybe this is intended though.
My repo structure looks like this:
-GitRepoMaster
----NormalCodeFolder
----GitSubmodule1
----GitSubmodule2
----GitSubmodule3
--------GitSubmodule3.1
--------GitSubmodule3.2
And on the treeview in Gitlense is see this:
-GitRepoMaster
----GitRepoMaster (GitSubmodule1)
----GitRepoMaster (GitSubmodule2)
----GitRepoMaster (GitSubmodule3)
But I suppose I expected to see this (more per SmartGit and Kracken):
-GitRepoMaster
----GitSubmodule1
----GitSubmodule2
----GitSubmodule3
--------GitSubmodule3.1
--------GitSubmodule3.2
Note the way the names look is different - () is missing and the tree should show a physical indentation.
And you show all the submodules.
Let me know what you think @eamodio
@andygikling Thanks! You can control the depth that GitLens searches for repositories by default by changing the gitlens.advanced.repositorySearchDepth setting. It currently defaults to 1 for performance reasons. Also, GitLens should automatically discover new repositories as you open new files from those repos.
Let me know if that works for you.
As for the naming -- I went with that structure to mirror the workspace folders you have open in vscode, although if you have only 1 workspace folder open then maybe that structure is overkill. I'll have to look into that a bit more.
Fantastic! Well done sir. Sorry I didn't know about the search depth option!
Naming decision makes sense. Thank you.
No worries at all (GitLens has LOTS of options :smile:).
Do you think this issue can be closed then?
Of course! Thank you.
Does the default of 1 for gitlens.advanced.repositorySearchDepth mean that it searches for submodules at the first level in a git repo? i.e. if I have a submodule at the root of my git repo, it should find it? For me, the submodule was not found until i opened a file in it even though it's at the root of my git repo.
Lol. I increased it to 2 and it found the git repos that were at depth 2 but not the one at depth 1.
Bump,
I have been having issues with this as well. GitLens only recognized the Master git repo initially.
Main Git Repo
|--File_Directory
|--SubModule A
|--SubModule B
|--SubModule C
|--SubModule C-1
|--SubModule D
I am able to get GitLens to recognize the submodules (including the nested one) If open files in each submodule. After VScode reloads though, they are gone and I have to open a file again.
I have tried the gitlens.advanced.repositorySearchDepth, but it hasnt changed anything (varied from 1 to 4).
I'm using subrepos inside the main git repo and can't see my subrepos as well, regardless of gitlens.advanced.repositorySearchDepth
For me, the submodule was not found until i opened a file in it even though it's at the root of my git repo.
This worked for me, thanks.
@ramusz1 To be clear, though, that is just a work-around. IMHO, the plugin should see all submodules without one having to navigate to one and open a file in one.
But if people are still seeing this, like @ramusz1 apparently is, why is this issue closed?
I also continue to experience this problem, with gitlens 10.2.2 on platformio. It sometimes works, and sometimes doesnt. Not sure why it starts and stops. I had a code review the other day, and all of a sudden my subrepos disappeared and I was SOL. it was really frustrating.
Could gitlens just look at the .gitmodules file to see where submodules should be?
Or could we specify paths to submodules inside of our workspace settings?
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@andygikling Thanks! You can control the depth that GitLens searches for repositories by default by changing the
gitlens.advanced.repositorySearchDepthsetting. It currently defaults to 1 for performance reasons. Also, GitLens should automatically discover new repositories as you open new files from those repos.Let me know if that works for you.
As for the naming -- I went with that structure to mirror the workspace folders you have open in vscode, although if you have only 1 workspace folder open then maybe that structure is overkill. I'll have to look into that a bit more.