cespinoza
cespinoza

Reputation: 1457

undo submodulization in git?

Our small team thought it would be a cool idea if the libraries (X, Y, Z) of our project A were separated into git submodules. Little did we realize how big of a pain this would be, especially since how project is still in early stages and is not well segregated yet. I think the project leader made the subdirectories submodules via the git filter-branch command (I can't ask him b/c he's on vacation).

Can we undo this somehow, and slurp the commits in the submodules back into the main project?

Examples of 'pain':

Upvotes: 4

Views: 362

Answers (3)

Mark Longair
Mark Longair

Reputation: 467311

I'm not necessarily recommending this as a course of action,ⁱ but I've written a script (unsubmodule.py) that should remove and then merge each submodule in as a subdirectory of the same name, preserving the history of the committed version of each submodule:

https://gist.github.com/763439

I haven't tested it much, so please be careful, e.g. only try it on a fresh clone initially. The script doesn't attempt to preserve any topic branches in the submodules, just the version committed in the supermodule.

ⁱ (Both for the reason Jonathan Leffler mentions in his comment and because I work on several projects that use submodules without major problems.)

Upvotes: 2

user502515
user502515

Reputation: 4444

Project A must point to X,Y,Z via 'git://' links instead of 'ssh://' if we want users to be able to check it out without ssh access, so we can't make changes directly to X via the A/X copy if we want to be able to push -- we have to clone it out separately, commit, push, then pull from the A/X copy.

Sounds like you want...

[remote "origin"]
        url = git://foobar
        pushurl = ssh://[email protected]/srv/git/foobar

Oh yeah-- for every change in X,Y, or Z we have to add a "Submodule updated" commit in the main project.

Submodules work like a skiplist, so this is to be expected. If you do not like it, consider using a server-side hook to update the main project whenever a commit in a subproject is done.

Upvotes: 1

Michal Čihař
Michal Čihař

Reputation: 10091

You can quite easily merge all repositories together into single one, they don't need to have anything common to merge them, you just need to prevent file conflicts. So first move all files in separate repositories into desired folder where they should be in the merged one and than just merge these separate repositories.

Upvotes: 1

Related Questions