英文:
How to tell git that I already changed the path of a submodule?
问题
我在以下路径有一个子模块:src/level_1/level_2/my_Submodule
。
在 VS Code 中,我将路径更改为:src/level_1/level_2/level_3/my_Submodule
。
在这种情况下,git 给我一个错误,提示 "未找到 my_Submodule 的路径"。
我如何让 git 使用我已经修改的新路径?
我不能使用 git mv old_path new_path
,因为我必须从 vscode 内部更改路径,这样 vscode 可以更新导入,以避免破损的路径。
我已经阅读了 stackoverflow 中所有类似的问题,但没有一个解决我上面解释的情况。
英文:
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.
答案1
得分: 0
-
你至少有两种选择(我认为):
-
前往更新 git 文件自己,将旧路径替换为新路径:存储库的
.submodules
文件,.git/config
文件,以及其他一些你可以通过cd
到.git
文件夹并使用类似 grep 的工具进行文件内容搜索(如.git/modules/<previous path>/config
)来找到的文件。
英文:
You have at least two options (I think):
-
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 https://stackoverflow.com/q/4604486/11107541 (git mv old/submod new/submod
). -
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 bycd
ing 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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论