English 中文(简体)
与Gite[复制]转移分流
原标题:Moving submodules with Git [duplicate]

Is there any way to move submodules within your superproject without removing them first and re-adding them ?

最佳回答

它类似于你如何去除一个小单元(见)。 我如何去除一个小单元?:

  • 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
  • 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

之后,我想到:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   .gitmodules
#       renamed:    old/parent/submodule -> new/parent/submodule
#
  • Finally commit the changes.
问题回答

我认为现在还没有。

There is a patch in the making for a teaching "git mv" how to handle moving submodules, including how to update the .gitmodules file.
But it is not there yet.
Simply switching a remote repo for an existing submodule is simpler, but not what you want.





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签