Search code examples
gitgithubvisual-studio-codegit-submodules

How to tell git that I already changed the path of a submodule?


I have a submodule at the following path: src/level_1/level_2/my_Submodule.

In VS Code, I changed the path to: src/level_1/level_2/level_3/my_Submodule.

In this case, git gives me an error that the "path to the my_Submodule is not found".

How can I make git to use the new path that I already modified?

I can't use git mv old_path new_path because I have to change the path from inside vscode itself, so vscode can update the imports, so I won't have broken paths.

I already read all the similar questions in stackoverflow and none of them solves the situation I explained above.


Solution

  • You have at least two options (I think):

    1. Since you want to do the move in VS Code to use it's auto-update-import-path feature, just do the move with VS Code to use that feature, then undo the move outside of VS Code (ex. with the mv unix command), and then take the normal route of doing things stated in the answers to How do I move an existing Git submodule within a Git repository? (git mv old/submod new/submod).

    2. Go and update the git files yourself, replacing the previous path with the new path: The repo's .submodules file, .git/config file, and several others you can find by cding into the .git folder and doing a file-content search (with a tool like grep) for the previous path, such as .git/modules/<previous path>/config.