如何删除Git子模块?为什么我不能git子模块rm模块名称?
当前回答
我最近发现了一个git项目,其中包含许多有用的git相关命令:https://github.com/visionmedia/git-extras
安装并键入:
git-delete-submodule submodule
然后事情就完成了。子模块目录将从repo中删除,并且仍然存在于文件系统中。然后可以提交更改,如:gitcommit-am“Remove the submodule”。
其他回答
您可以使用别名自动化其他人提供的解决方案:
[alias]
rms = "!f(){ git rm --cached \"$1\";rm -r \"$1\";git config -f .gitmodules --remove-section \"submodule.$1\";git config -f .git/config --remove-section \"submodule.$1\";git add .gitmodules; }; f"
将其放入git配置中,然后可以执行:git rms path/to/submodule
对于数字2.17及以上,它只是:
git submodule deinit -f {module_name}
git add {module_name}
git commit
我不得不进一步执行John Douth的步骤,并将其cd到子模块的目录中,然后删除Git存储库:
cd submodule
rm -fr .git
然后,我可以将文件作为父Git存储库的一部分提交,而无需对子模块的旧引用。
我最近发现了一个git项目,其中包含许多有用的git相关命令:https://github.com/visionmedia/git-extras
安装并键入:
git-delete-submodule submodule
然后事情就完成了。子模块目录将从repo中删除,并且仍然存在于文件系统中。然后可以提交更改,如:gitcommit-am“Remove the submodule”。
您必须删除.gitmodules和.git/config中的条目,并从历史记录中删除模块的目录:
git rm --cached path/to/submodule
如果你在git的邮件列表上写东西,很可能有人会为你编写一个shell脚本。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别