Files
noco-auto/demodule.sh
2025-12-02 09:00:25 +08:00

22 lines
812 B
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "🧹 正在移除所有 Git Submodule 配置(保留文件)..."
# 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 "🎉 所有子模块配置已移除,文件全部保留!"