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"
复制代码
相关推荐
qq_435287926 小时前
第9章 夸父逐日与后羿射日:死循环与进程终止?十个太阳同时值班的并行冲突
java·开发语言·git·死循环·进程终止·并行冲突·夸父逐日
AIMath~13 小时前
Git 子模块(Submodule)目录结构清除实战复盘
git
切糕师学AI13 小时前
Ubuntu 下 Git 完全使用指南
linux·git·ubuntu
一袋米扛几楼9815 小时前
【Git】规范化协作:详解 GitHub 工作流中的 Issue、Branch 与 Pull Request 最佳实践
前端·git·github·issue
尘埃落定wf16 小时前
# GitHub CLI:告别繁琐的 Git 命令,让开发更高效
git·github
恋喵大鲤鱼16 小时前
git clone
git·git clone
金牛IT18 小时前
Gogs 轻量级 Git 服务器搭建与使用
运维·服务器·git
Qres8211 天前
Git安装记录
git
wj3055853781 天前
Codex + Git 开发环境配置指南(WSL版)
linux·运维·git
楠枬1 天前
Git 分支管理
git