gitsubnodule的使用

git 仓库中添加子仓库

  • git submodule add <子module的远程仓库地址>

git 删除子仓库

  • Delete the relevant section from the .gitmodules file.

  • Stage the .gitmodules changes git add .gitmodules.

  • Delete the relevant section from .git/config .

  • Run git rm –cached path_to_submodule (no trailing slash).

  • Run rm -rf .git/modules/path_to_submodule.


    问题记录:

    问题一: 重新add子module的时候提示: ‘repo’ already exists in the index

    解决办法:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    $ rm -Rf rack/
    $ git submodule add git@github.com:schacon/rack.git rack'rack' already exists in the index
    You have to unstage the rack directory first. Then you can add the submodule:
    $ git rm -r rack
    $ git submodule add git@github.com:schacon/rack.git rack

​ 在.gitmodules配置文件中删除子module的相关配置后要记得使用

git rm –cached path_to_submodule (no trailing slash).删除缓存否则别人删除的子module会一直报url找不到的错误

盛艳明 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!