Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Note:</strong> As mentioned in the comments this answer refers to the steps needed with older versions of git. Git now has native support for moving submodules: </p> <blockquote> <p>Since git 1.8.5, <code>git mv old/submod new/submod</code> works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving.</p> </blockquote> <hr> <p>It’s similar to how you remove a submodule (see <a href="https://stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule">How do I remove a submodule?</a>):</p> <ol> <li>Edit <code>.gitmodules</code> and change the path of the submodule appropriately, and put it in the index with <code>git add .gitmodules</code>.</li> <li>If needed, create the parent directory of the new location of the submodule (<code>mkdir -p new/parent</code>).</li> <li>Move all content from the old to the new directory (<code>mv -vi old/parent/submodule new/parent/submodule</code>).</li> <li>Make sure Git tracks this directory (<code>git add new/parent</code>).</li> <li>Remove the old directory with <code>git rm --cached old/parent/submodule</code>.</li> <li>Move the directory <code>.git/modules/old/parent/submodule</code> with all its content to <code>.git/modules/new/parent/submodule</code>.</li> <li>Edit the <code>.git/modules/new/parent/config</code> file, make sure that worktree item points to the new locations, so in this example it should be <code>worktree = ../../../../../new/parent/module</code>. Typically there should be two more <code>..</code> then directories in the direct path in that place.</li> <li><p>Edit the file <code>new/parent/module/.git</code>, make sure that the path in it points to the correct new location inside the main project <code>.git</code> folder, so in this example <code>gitdir: ../../../.git/modules/new/parent/submodule</code>.</p> <p><code>git status</code> output looks like this for me afterwards:</p> <pre><code># On branch master # Changes to be committed: # (use "git reset HEAD &lt;file&gt;..." to unstage) # # modified: .gitmodules # renamed: old/parent/submodule -&gt; new/parent/submodule # </code></pre></li> <li><p>Finally, commit the changes.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload