Cancel submodulation in git?

Our small team thought it would be great if the libraries (X, Y, Z) of our project A were divided into git submodules. You never know how great the pain will be, especially since the project is still in its early stages and has not yet been isolated. I think the project manager made subdirectories of subdirectories through the git filter-branch command (I cannot ask him to b / c he is on vacation).

Can we somehow undo this and then intercept the commits in the submodules back to the main project?

Examples of "pain":

  • Project A should point to X, Y, Z via the 'git: //' links instead of 'ssh: //' if we want users to be able to check it without ssh, t to make changes directly to X through a copy of A / X , if we want us to be able to click - we must clone it separately, commit, click, and then extract from the copy of A / X.
  • In addition, TortoiseGit and other Windows tools do not seem to understand the submodules, or at least they do not make it transparent, just like cloning, so now we are collecting things with silly scripts and hooks.
  • Oh yes ... for every change in X, Y or Z, we have to add the “Updated submodule” sales cart to the main project. I assume that the submodules are for much more mature projects that are supported by different teams.
+4
source share
3 answers

You can easily merge all repositories together into one, they don’t have to have something in common to combine them, you just need to prevent file conflicts. Therefore, first move all the files to separate repositories in the desired folder, where they should be in the combined, and not just merge these separate repositories.

+1
source

I do not necessarily recommend this as a course of action, but I wrote a script (unsubmodule.py) that should remove and then merge each submodule as a subdirectory of the same name, keeping a history of the perfect version of each submodule:

https://gist.github.com/763439

I have not tested very much, so please be careful, for example. first try on a new clone. The script does not try to save any topic branches in submodules, but only the version made in the supermodule.

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

+2
source

Project A should point to X, Y, Z via the 'git: //' links instead of 'ssh: //' if we want users to be able to check it without ssh, t to make changes directly to X through a copy of A / X , if we want us to be able to click - we must clone it separately, commit, click, and then extract from the copy of A / X.

Looks like you want ...

  [remote "origin"]
         url = git: // foobar
         pushurl = ssh: // user@corp.com / srv / git / foobar

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

Submodules work like a skiplist, so this is to be expected. If you don't like this, consider using a server-side hook to update the main project whenever a commit is made to a subproject.

+1
source

Source: https://habr.com/ru/post/1333523/


All Articles