git删除submodule

复制代码
# Git 子模块删除教程(以 ./prome 为例)

本文说明如何彻底删除 Git 子模块,以避免残留配置导致后续仓库异常。示例子模块路径为 `./prome`。

---

## 删除步骤

### 1. 删除 `.gitmodules` 中的子模块配置
```bash
git config -f .gitmodules --remove-section submodule.prome 2>/dev/null
git add .gitmodules

2. 删除 .git/config 中对应的配置

复制代码
git config --remove-section submodule.prome 2>/dev/null

3. 删除 Git 存储的子模块仓库目录

复制代码
rm -rf .git/modules/prome

4. 删除工作区中的子模块目录

复制代码
git rm -f prome

5. 提交删除记录

复制代码
git commit -m "Remove submodule prome"

完整命令汇总

复制代码
git config -f .gitmodules --remove-section submodule.prome 2>/dev/null
git add .gitmodules
git config --remove-section submodule.prome 2>/dev/null
rm -rf .git/modules/prome
git rm -f prome
git commit -m "Remove submodule prome"
复制代码
相关推荐
青禾8373 小时前
Git 与 SVN 完全指南:从集中式到分布式的版本控制
分布式·git·svn
2301_800954993 小时前
Git 版本控制核心概念详解:从集中式到分布式
分布式·git
Draw Stars13 小时前
Git BASH安装教程
开发语言·git·bash
Akiyama_Mio-Kon13 小时前
2026 最新:Dify 本地 Docker 部署完整教程(Windows + Git Bash)
windows·git·docker
福如意如我心意18 小时前
Git Worktree开发指南
git
Patrick_Wilson1 天前
为什么gitlab的MR会默认有一个merge commit
前端·git·gitlab
是乐乐啊呀1 天前
版本控制 GIT 和 SVN
git·svn
夜鸣笙笙1 天前
Git详细安装流程
git
瑞码空间2 天前
git知识点黄金笔记
笔记·git·elasticsearch
----云烟----2 天前
Git 提交忽略某些文件方法
git