删除git submodule最为精准的一片描述文章

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 12:10   33   0

转自 http://davidwalsh.name/git-remove-submodule

For many git-based projects, submodules are useful in avoiding duplicate work and easing utility library updates. There are times, however, when a submodule needs to be removed from a project. Submodules aren't removed with git rm submoduledir, they must be removed in a more tedious, manual fashion. There are many unclear explanations of how to remove a submodule but I found one onStack Overflowthat's concise, so I thought I'd share it. The steps are as follows:

  1. Delete the relevant section from the.gitmodulesfile. The section would look similar to:
    [submodule "vendor"]
     path = vendor
     url = git://github.com/some-user/some-repo.git
  2. Stage the.gitmoduleschanges via command line using:git add .gitmodules
  3. Delete the relevant section from.git/config, which will look like:
    [submodule "vendor"]
     url = git://github.com/some-user/some-repo.git
  4. Rungit rm --cached path/to/submodule. Don't include a trailing slash -- that will lead to an error.
  5. Runrm -rf .git/modules/submodule_name
  6. Commit the change:
  7. Delete the now untracked submodule filesrm -rf path/to/submodule

Those steps will get you rid of that unwanted submodule. A lot harder than adding one, eh?

备注:如果工程与工程之前互相依赖,则需要分别删除后,在进行submodule的关联

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP