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"
复制代码
相关推荐
江畔柳前堤3 小时前
第13章:docker生产环境部署实战
运维·git·docker·容器·代码复审
GuHenryCheng6 小时前
【ESP32】ESP-IDF开发环境搭建(cursor)
git·stm32·单片机·学习
kaka。。6 小时前
GIT安装+代码推送
git
明理的路灯7 小时前
安装 git 开发工具
git
偏爱自由 !8 小时前
5:IDEA中git的使用--git fetch 和 git pull 和解决冲突
git·elasticsearch·intellij-idea
偏爱自由 !9 小时前
2:IDEA中git的使用--基础操作
java·git·intellij-idea
青山木1 天前
快速搭建免费的个人博客网站:Hexo + GitHub Pages + Butterfly 完整指南
git·github
江畔柳前堤1 天前
第16章:docker企业级实战综合项目
运维·git·安全·docker·容器·eureka
偏爱自由 !1 天前
一(0.1):配置git
java·git·intellij-idea
江畔柳前堤1 天前
第11章:Docker 安全加固
运维·git·安全·docker·容器·eureka·github