如何删除git submodule add的hugo主题

如果你在 Hugo 项目中使用了 Git Submodule 来添加主题,并且现在想要移除它,你可以按照以下步骤操作:

移除 Hugo 主题 Submodule

  1. 从 Git 配置中移除 submodule
    git submodule deinit -f themes/<theme-name>
    
  2. .git/modules 中删除相关文件
    rm -rf .git/modules/themes/<theme-name>
    
  3. 从 Git 记录中移除 submodule
    git rm -f themes/<theme-name>
    
  4. 提交更改
    git commit -m "Removed submodule: <theme-name>"
    

(可选) 清理无用的 submodule 数据

如果你想确保没有残留的 submodule 数据,可以运行:

git gc --prune=now

这样,你的 Hugo 主题 submodule 就完全移除了。🚀