How do I move an existing Git submodule within a Git repository?

后端 未结 10 666
面向向阳花
面向向阳花 2020-11-29 14:39

I would like to change the directory name of a Git submodule in my Git superproject.

Lets suppose I have the following entry in my .gitmodules file:

10条回答
  •  野性不改
    2020-11-29 15:15

    The given solution did not work for me, however a similar version did...

    This is with a cloned repository, hence the submodule git repos are contained in the top repositories .git dir. All cations are from the top repository:

    1. Edit .gitmodules and change the "path =" setting for the submodule in question. (No need to change the label, nor to add this file to index.)

    2. Edit .git/modules/name/config and change the "worktree =" setting for the submodule in question

    3. run:

      mv submodule newpath/submodule
      git add -u
      git add newpath/submodule
      

    I wonder if it makes a difference if the repositories are atomic, or relative submodules, in my case it was relative (submodule/.git is a ref back to topproject/.git/modules/submodule)

提交回复
热议问题