Git-如何在子模块中删除未跟踪的文件夹 [英] Git - How to remove untracked folder in submodules
问题描述
我尝试签出并使用git checkout命令丢弃了该库,但似乎对我不起作用.
I tried checkout and discard this library with git checkout command, but seems it does not work for me.
我试图删除此文件夹,但是之后git希望我将此删除的文件夹添加到提交中,但是我不想跟踪它或将其推送到服务器.
I tried to remove this folder, but after that git wants me to add this deleted folder to a commit, but I don't want to track it or push to server.
未针对提交进行的更改:(使用"git add ..."进行更新 将提交的内容)(使用"git checkout-..."丢弃 工作目录中的更改)(提交或丢弃未跟踪的或 子模块中的已修改内容)
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) (commit or discard the untracked or modified content in submodules)
已修改:库/some_sdk(未跟踪的内容)
modified: Libraries/some_sdk (untracked content)
推荐答案
一种方法是进入该子模块文件夹并在其中进行操作:
One way would be to go in that submodule folder and do in it:
cd /path/to/repo
cd Libraries/some_sdk
git reset --hard
那应该重置它的索引.
然后,其父存储库中的git status
应该再提及(子模块)文件夹.
Then, a git status
from its parent repo should mention the (submodule) folder anymore.
我不想跟踪它或将其推送到服务器.
I don't want to track it or push to server.
不会从父仓库中跟踪它:所述父仓库仅引用 gitlink (
It won't be tracked from the parent repo: said parent repo only references the gitlink (special entry in the index) representing the SHA1 of the submodule repo.
我试图删除此文件夹,但是之后git希望我将此删除的文件夹添加到提交中
I tried to remove this folder, but after that git wants me to add this deleted folder to a commit
要删除子模块,请参阅"如何删除子模块?"
To remove a submodule, see "How do I remove a submodule?"
cd /path/to/repo
git submodule deinit Libraries/some_sdk
git rm Libraries/some_sdk
# note: no trailing slash
rm -rf .git/modules/Libraries/some_sdk
这篇关于Git-如何在子模块中删除未跟踪的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!