Getting started
Committing
Browsing the history
Undoing
Staging
Git diff
Merging
Ignoring files and folders
Working with remotes
Submodules
Clone a git repository having submodules
Updating a submodule
Adding a submodule
Setting a submodule to follow a branch
Moving a submodule
Removing a submodule
Aliases
Rebasing
Configuration
Branching
rev-list
Squashing
Cherry picking
Recovering
git clean
.gitattributes
.mailmap
Different workflows
Pulling
Hooks
Cloning repositories
Stashing
Subtrees
Renaming
Pushing
Internals
git-tfs
Empty directories in git
git-svn
Archive
Rewriting history with filter-branc
Migrating to git
Show
Resolving merge conflicts
Bundles
Display commit history graphically with gitk
Bisecting to find faulty commits
Blaming
Git revisions syntax
Worktrees
Git remote
Git large file storage
git patch
git statistics
git send-email
git gui clients
reflog - restoring commits not shown in git log
TortoiseGit
External merge and diff tools
Update object name in reference
Git branch name on Bash Ubuntu
Git client-side hooks
Git rerer
Change git repository name
git tagging
tidying up your local and remote repository
diff tree
Contributors

Moving a submodule

suggest change

Run:

$ git mv old/path/to/module new/path/to/module
  1. Edit .gitmodules and change the path of the submodule appropriately, and put it in the index with git add .gitmodules.
  2. If needed, create the parent directory of the new location of the submodule (mkdir -p new/path/to).
  3. Move all content from the old to the new directory (mv -vi old/path/to/module new/path/to/submodule).
  4. Make sure Git tracks this directory (git add new/path/to).
  5. Remove the old directory with git rm –cached old/path/to/module.
  6. Move the directory .git/modules/old/path/to/module with all its content to .git/modules/new/path/to/module.
  7. Edit the .git/modules/new/path/to/config file, make sure that worktree item points to the new locations, so in this example it should be worktree = ../../../../../old/path/to/module. Typically there should be two more .. then directories in the direct path in that place. . Edit the file new/path/to/module/.git, make sure that the path in it points to the correct new location inside the main project .git folder, so in this example gitdir: ../../../.git/modules/new/path/to/module.

    git status output looks like this afterwards:

    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       modified:   .gitmodules
    #       renamed:    old/path/to/submodule -> new/path/to/submodule
    #
  8. Finally, commit the changes.

This example from Stack Overflow, by Axel Beckert

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents