Adding a worktree from a working copy with submodules doesn't work.
In the config file I have
[submodule]
recurse = trueIt that's not present, I don't find the problem.
# Preparation
$ git --version git version 2.20.1
$ cd /tmp/
$ git init main_repo Initialized empty Git repository in /tmp/main_repo/.git/
$ git init repo_submod Initialized empty Git repository in /tmp/repo_submod/.git/
$ cd repo_submod
$ echo Some text > file.txt
$ git add file.txt
$ git ci -m "First commit in subrepo" [master (root-commit) ebc9325] First commit in subrepo 1 file changed, 1 insertion(+) create mode 100644 file.txt
$ cd ../main_repo/
$ git submodule add /tmp/repo_submod submod Cloning into '/tmp/main_repo/submod'... done.
$ git ci -am "First commit, add submodule" [master (root-commit) 695b3a1] First commit, add submodule 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 submod
# Problem 1 (can't run worktree add)
$ git worktree add ../wt -b new_branch Preparing worktree (new branch 'new_branch') fatal: exec '--super-prefix=submod/': cd to 'submod' failed: No such file or directory error: Submodule 'submod' could not be updated. error: Submodule 'submod' cannot checkout new HEAD. fatal: Could not reset index file to revision 'HEAD'.
The new directory (../wt) is created and removed (seen with strace). The new branch is created and not removed.
# Problem 2 (submodule status seems not to detect some cases)
$ pwd /tmp/main_repo
$ git submodule status ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod (heads/master)
$ rm submod/file.txt submod/.git
$ git submodule status ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod
So, I have a plain, empty directory where the submodule should be. Not having any 'first char', I'd expect it to be checked out and up to date. Is this expected?
Thanks a lot for the work!