generated from template/apps-template
update
This commit is contained in:
25
demodule.sh
25
demodule.sh
@@ -1,22 +1,3 @@
|
|||||||
#!/bin/bash
|
# !/bin/sh
|
||||||
|
## 功能:彻底删除 git 子模块相关信息
|
||||||
echo "🧹 正在移除所有 Git Submodule 配置(保留文件)..."
|
git submodule deinit -f . && rm -rf .git/modules && git rm -f $(git config --file .gitmodules --get-regexp path | awk '{print $2}') && rm -f .gitmodules
|
||||||
|
|
||||||
# 1. 取消注册所有子模块(关键!保留文件)
|
|
||||||
git submodule foreach --quiet 'git submodule deinit -- "$name"'
|
|
||||||
|
|
||||||
# 2. 删除 .gitmodules 中的所有子模块配置段
|
|
||||||
git config -f .gitmodules --remove-section submodule 2>/dev/null
|
|
||||||
|
|
||||||
# 3. 从 Git 索引中移除所有子模块(不删文件!)
|
|
||||||
git submodule foreach --quiet 'git rm --cached "$name"'
|
|
||||||
|
|
||||||
# 4. 清理残留的 .git/modules/ 目录(保险)
|
|
||||||
rm -rf .git/modules/* 2>/dev/null
|
|
||||||
|
|
||||||
# 5. 提交变更
|
|
||||||
git add .gitmodules
|
|
||||||
git add --all
|
|
||||||
git commit -m "Remove all submodules, keep files" 2>/dev/null && echo "✅ 已提交变更" || echo "ℹ️ 无变更需提交(可能已清理)"
|
|
||||||
|
|
||||||
echo "🎉 所有子模块配置已移除,文件全部保留!"
|
|
||||||
Reference in New Issue
Block a user