Skip to contentSkip to conversation

git-submodule-move - Easily move submodules

New Feature TJ 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore

TJ

author
#0 lore raw

I've recently had need to re-arrange more than ten submodules within a project and discovered there is apparently no easy way to do it.

Using some suggestions I found on Stack Overflow I eventually figured out the steps required. Because the steps can be complex I thought it would be handy to have a tool to automate the functionality.

I have put together a reasonably bullet-proof shell script "git-submodule-move" that does the job pretty well. I've put it through quite a bit of testing and trusted it with my own project and it has performed well.

I've published to github so others can use and improve it.

https://github.com/iam-TJ/git-submodule-move

#1 lore raw

Re: Moving (renaming) submodules, recipe/script

Quoted 2 lines · TJ

I've recently had need to re-arrange more than ten submodules within a project and discovered there is apparently no easy way to do it.

I ran into a similar problem last month, and wrote a similar script
[1] ;). There are a few other related threads you might be interested in:

Quoted 11 lines · W. Trevor King

Today I had to move my first submodule, and I discovered that Git's
support for this is pretty limited. There have been a few patch
series attempting to address this [1,2], but none of them seems to
have pushed through into master (although I can't put my finger on a
reason for why). There are also some SO postings discussing this
[3,4]. It would be nice if git mv worked out of the box on
…
[1]: http://thread.gmane.org/gmane.comp.version-control.git/88720
[2]: http://thread.gmane.org/gmane.comp.version-control.git/143250
[4]: http://stackoverflow.com/questions/4323558/moving-submodules-with-git
[3]: http://stackoverflow.com/questions/4604486/how-do-i-move-an-existing-git-submodule-within-a-git-repository

The long-term solution is probably Jens' branch:

Quoted 5 lines · Jens Lehmann

I´m currently working on teaching mv to move submodules and intend to send those patches to the list after finishing submodule deinit. Please see
https://github.com/jlehmann/git-submod-enhancements/commits/mv-submodules
for the current state of this series.

Cheers,
Trevor

[1]: http://thread.gmane.org/gmane.comp.version-control.git/212861

Signature · 2 lines
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
#2 lore raw
In reply to TJ

Am 03.02.2013 23:36, schrieb TJ:

Quoted 11 lines

I've recently had need to re-arrange more than ten submodules within a project and discovered there is apparently no easy way to do it.

Using some suggestions I found on Stack Overflow I eventually figured out the steps required. Because the steps can be complex I thought it would be handy to have a tool to automate the functionality.

I have put together a reasonably bullet-proof shell script "git-submodule-move" that does the job pretty well. I've put it through quite a bit of testing and trusted it with my own project and it has performed well.

I've published to github so others can use and improve it.

https://github.com/iam-TJ/git-submodule-move

I'd propose to drop these two steps:
updating super-repository's submodule name
moving super-repository's submodule repository

Changing the name makes the moved submodule a completely new entity and will lead to a reclone of the repository as soon as recursive checkout materializes. And Trevor already mentioned the long term solution which is to teach "git mv" to do all that, which is next on my list.