Skip to content

如何优雅地删掉 Git submodule (How effectively delete a git submodule) #16

@yangruihan

Description

@yangruihan

如何优雅地删掉 Git submodule (How effectively delete a git submodule)

参考地址:https://gist.github.com/myusuf3/7f645819ded92bda6677

步骤

  • .gitmodules文件中删除对应子模块的节(section)
  • 通过git add .gitmodules命令将.gitmodules文件添加到待提交区
  • .git/config文件中删除对应子模块的节(section)
  • 运行git rm --cached xxxx(子模块路径)命令
  • 运行rm -rf .git/modules/xxxx(子模块路径)命令
  • 通过git commit -m "删除子模块"命令提交删除操作
  • 通过rm -rf xxxx(子模块路径)将子模块彻底从项目中删除

原文

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions