git submodule 删除及修改
git 2020-01-15 15:31:48

1. 删除子模块

PHP Code复制内容到剪贴板
  1. # 逆初始化模块,其中{MOD_NAME}为模块目录,执行后可发现模块目录被清空  
  2. git submodule deinit {MOD_NAME}   
  3. # 删除.gitmodules中记录的模块信息(--cached选项清除.git/modules中的缓存)  
  4. git rm --cached {MOD_NAME}   
  5. # 提交更改到代码库,可观察到'.gitmodules'内容发生变更  
  6. git commit -am "Remove a submodule."  

 

2. 修改模块URL

修改'.gitmodules'文件中对应模块的”url“属性;

使用 git submodule sync 命令,将新的URL更新到文件.git/config;

 

示例:

1、查看当前子模块:

 

  External git:(master) git submodule status

 

 c3c0cac3d4c176b04404e3574d62b51776277384 RxSwift (3.2.0-1147-gc3c0cac3)

 0b02f5b338f7f9b5a857c8dba9ffa09e3c0548ac YHPhotoKit (0.2.1)

 

2、删除其中一个模块

 

  External git:(master) git submodule deinit YHPhotoKit

error: the following file has changes staged in the index:

    uniapp-IOS原生插件/libWeexYYJPushIM3.0/libWeexYYJPushIM/YYJPushIM/External/YHPhotoKit

(use --cached to keep the file, or -f to force removal)

fatal: Submodule work tree 'YHPhotoKit' contains local modifications; use '-f' to discard them

 

  External git:(master) git rm --cached YHPhotoKit 

rm 'uniapp-IOS原生插件/libWeexYYJPushIM3.0/libWeexYYJPushIM/YYJPushIM/External/YHPhotoKit'

 

  External git:(master) ll

total 0

drwxr-xr-x   9 yoyo  staff   288B  1 15 11:02 MBProgressHUD

drwxr-xr-x  40 yoyo  staff   1.3K  1 15 11:22 RxSwift

drwxr-xr-x   9 yoyo  staff   288B  1 15 15:27 YHPhotoKit

 

  External git:(master) git submodule status

 c3c0cac3d4c176b04404e3574d62b51776277384 RxSwift (3.2.0-1147-gc3c0cac3)

 

3、添加一个子模块

  External git:(master) git submodule add git@github.com:ReactiveX/RxSwift.git 

 

本文来自于:http://www.yoyo88.cn/study/git/488.html

Powered by yoyo苏ICP备15045725号