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

Edit . Gitmodules and change the path of the submodule appropriately, and put it in the index with "git add . Gitmodules If needed, create the parent directory of the new location of the submodule: "mkdir -p new/parent" and make sure git tracks this directory ("git add new/parent") Move all content from the old to the new directory: "mv -vi old/parent/submodule new/parent/submodule Remove the old directory with "git rm --cached old/parent/submodule Looks like this for me afterwards: On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: .

Gitmodules # renamed: old/parent/submodule -> new/parent/submodule Finally commit the changes.

Edit . Gitmodules and change the path of the submodule appropriately, and put it in the index with "git add . Gitmodules".

If needed, create the parent directory of the new location of the submodule: "mkdir -p new/parent" and make sure git tracks this directory ("git add new/parent") Move all content from the old to the new directory: "mv -vi old/parent/submodule new/parent/submodule" Remove the old directory with "git rm --cached old/parent/submodule". Looks like this for me afterwards: # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: . Gitmodules # renamed: old/parent/submodule -> new/parent/submodule # Finally commit the changes.

After that you need to manually clean up your submodules . Git/config, right? Or is there a command which does that?

– thisch Jun 12 at 12:15 Is this still the suggested way to to that? – Drake Guan Jul 11 at 6:57 FWIW, I was unable to get this to work - perhaps there's a step missing that I'm unaware of? – Allen George Aug 9 at 22:07 When you update .

Gitmodules make sure you update both that path configuration and the submodule's name. For example, in moving foo/module to bar/module you must change in . Gitmodules the section submodule "foo/module" to submodule "bar/module", and under that same section path = foo/module to path = bar/module.

Also, you must change in . Git/config the section submodule "foo/module" to submodule "bar/module". – wilhelmtell Nov 12 at 14:11.

The string in quotes after "submodule" doesn't matter. You can change it to "foobar" if you want. It's used to find the matching entry in ".

Git/config". Therefore, if you make the change before you run "git submodule init", it'll work fine. If you make the change (or pick up the change through a merge), you'll need to either manually edit .

Git/config or run "git submodule init" again. If you do the latter, you'll be left with a harmless "stranded" entry with the old name in . Git/config.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions