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

转自  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 on Stack Overflowthat's concise, so I thought I'd share it.  The steps are as follows:

  1. Delete the relevant section from the .gitmodules file.  The section would look similar to:
    [submodule "vendor"]
    	path = vendor
    	url = git://github.com/some-user/some-repo.git
  2. Stage the .gitmodules changes 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. Run git rm --cached path/to/submodule .  Don't include a trailing slash -- that will lead to an error.
  5. Run rm -rf .git/modules/submodule_name
  6. Commit the change:
  7. Delete the now untracked submodule files rm -rf path/to/submodule

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

 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值