Jim's Blog
Toggle navigation
Jim's Blog
Home
About Me
Archives
Tags
Remove a submodule in Git
git
2016-10-20 02:41:23
276
0
0
jim
git
# 0. Add a submodule ```shell git submodule add [-b <branch>] <repository> [<path>] git submodule init git submodule update ``` # 1. Remove config entries: ```shell git config -f .git/config --remove-section submodule.$submodulepath git config -f .gitmodules --remove-section submodule.$submodulepath ``` # 2. Remove directory from index: ```shell git rm --cached $submodulepath ``` # 3. Commit # 4. Delete unused files: ```shell rm -rf $submodulepath rm -rf .git/modules/$submodulepath ``` # Background When you do git submodule add, it only adds it to `.gitmodules`, but once you did git submodule init, it added to `.git/config`. So if you wish to remove the modules, but be able to restore it quickly, then do just this: ```shell git rm --cached $submodulepath git config -f .git/config --remove-section submodule.$submodulepath ``` It is a good idea to do git rebase HEAD first and git commit at the end, if you put this in a script.
Pre:
Revert while keeping earlier commit records in Git
Next:
使用Go实现TLS 服务器和客户端
0
likes
276
新浪微博
微信
腾讯微博
QQ空间
人人网
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus
Table of content