threads / discuss / 32819

[New Feature] git-submodule-move - Easily move submodules

Subject: [New Feature] git-submodule-move - Easily move submodules

## tl;dr

3 messages between Feb 3, 2013 and Feb 4, 2013.

replies: 2people: 3as markdown or json

TJ· Feb 3, 2013, 22:36 UTC · lore
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
W. Trevor King· Feb 3, 2013, 23:38 UTC · re: TJ · lore

Re: Moving (renaming) submodules, recipe/script

On Sun, Feb 03, 2013 at 10:36:17PM +0000, TJ wrote:
> 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:

On Sun, Jan 06, 2013 at 07:36:03PM -0500, W. Trevor King wrote:
Show 11 quoted lines
> 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:
On Mon, Jan 07, 2013 at 07:59:53AM +0100, Jens Lehmann wrote:
Show 5 quoted lines
> 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
-- 
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
Jens Lehmann· Feb 4, 2013, 20:14 UTC · re: TJ · lore

Re: [New Feature] git-submodule-move - Easily move submodules

Am 03.02.2013 23:36, schrieb TJ:
Show 11 quoted 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.

← back to recent threads