Rename a git submodule

前端 未结 7 2135
-上瘾入骨i
-上瘾入骨i 2020-12-04 05:32

Is there some easy way to rename a git submodule directory (other than going through the entire motion of deleting it and re-adding it with a new destination name).

<
7条回答
  •  既然无缘
    2020-12-04 06:33

    It's not possible to rename it, so you've to remove it first (deinit) and add it again.

    So after removing it:

    git submodule deinit 
    git rm --cached 
    

    you may also double check and remove the references to it in:

    • .gitmodules
    • .git/config
    • remove reference folder from .git/modules/ (best to make a backup), as each folder has config file where it keeps the reference to its worktree

    then stage your changes by committing any changes to your repo by:

    git commit -am 'Removing submodule.'
    

    and double check if you don't have any outstanding issues by:

    git submodule update
    git submodule sync
    git submodule status
    

    so now you can add the git submodule again:

    git submodule add --name  git@github.com:foo/bar.git 
    

提交回复
热议问题