When working in a git submodule, there's an error message something like this:
fatal: Could not chdir to '../../../../../some-dir': No such file or directory
Though I don't know what exactly caused it in my case, I suspect it was renaming a parent directory of my submodule directory.
git mv sidesteps the problem and I didn't use it, or maybe I did use it but it doesn't sidestep the problem... Either way, I ended up with a mess.
In my case, the
.git file in the submodule directory is a file, with an entry that points to the actual git repo:
At that path, there is a git repo, and in that repo is a
config file with an entry for
worktree = ../../../../../www/path/to/submodule
The solution was to fix all those paths.
I had renamed
web, so these are the steps I took:
- In the main repo directory, change the location of the submodule repo:
mv .git/modules/www .git/modules/web
- In the submodule repo directory
configfile, change the entry for
worktree = ../../../../../web/path/to/submodule
- In the submodule directory
.gitfile, change the entry for
- In the main repo
.git/configfile, change the submodule declaration:
[submodule "web/path/to/submodule"] url = submodule-origin-repo-url