Git Submodule使用完整教程(小结)(17)
➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) git rm -r --cached libs/ rm 'libs/lib1' rm 'libs/lib2' ➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) ✗ rm -rf libs 2、删除.gitmodules的内容(或者整个文件) 因为本例只有两个子模块,直接删除文件: ➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) ✗ rm .gitmodules 如果仅仅删除某一个submodule那么打开.gitmodules文件编辑,删除对应submodule配置即可。 3、删除.git/config的submodule配置 源文件: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = /home/henryyan/submd/ws/../repos/project1.git [branch "master"] remote = origin merge = refs/heads/master [submodule "libs/lib1"] url = /home/henryyan/submd/repos/lib1.git [submodule "libs/lib2"] url = /home/henryyan/submd/repos/lib2.git 删除后: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = /home/henryyan/submd/ws/../repos/project1.git [branch "master"] remote = origin merge = refs/heads/master 4、提交更改 ➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) ✗ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: libs/lib1 # deleted: libs/lib2 # # Changes not staged for commit: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: .gitmodules # ➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) ✗ git add .gitmodules ➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) ✗ git commit -m "删除子模块lib1和lib2" [master 5e2ee71] 删除子模块lib1和lib2 3 files changed, 0 insertions(+), 8 deletions(-) delete mode 100644 .gitmodules delete mode 160000 libs/lib1 delete mode 160000 libs/lib2 ➜ henryyan@hy-hp ~/submd/ws/project1-remove-submodules git:(master) git push Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 302 bytes, done. Total 2 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (2/2), done. To /home/henryyan/submd/ws/../repos/project1.git 756e788..5e2ee71 master -> master </file></file></file> 4.结束语 对于Git Submodule来说在刚刚接触的时候多少会有点凌乱的赶紧,尤其是没有接触过svn:externals。 本文从开始创建项目到使用git submodule的每个步骤以及细节、原理逐一讲解,希望到此读者能驾驭它。 学会了Git submdoule你的项目中再也不会出现大量重复的资源文件、公共类库,更不会出现多个版本,甚至一个客户的多个项目风格存在各种差异。 来源: <> 拉取所有子模块 git submodule foreach git pull git submodule foreach --recursive git submodule init git submodule foreach --recursive git submodule update 到此这篇关于Git Submodule使用完整教程(小结)的文章就介绍到这了,更多相关Git Submodule使用内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家! (编辑:ASP站长网) |