Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove git submodule but keep files

Tags:

git

I have a git submodule that I would like to become part of my main project (since I have a lot of project specific code that will go into the submodule).

So I'd like to remove the git references to the submodule and add the files to my main git repository.

But how ?

like image 478
Askbar Avatar asked Nov 05 '14 08:11

Askbar


People also ask

Why you should not use git submodules?

This is because of some major drawbacks around git submodules, such as being locked to a specific version of the outer repo, the lacking of effective merge management, and the general notion that the Git repository itself doesn't really know it's now a multi-module repository.

Does git pull pull submodules?

Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .

Do I need git submodules?

Git submodules allow you to keep a git repository as a subdirectory of another git repository. Git submodules are simply a reference to another repository at a particular snapshot in time. Git submodules enable a Git repository to incorporate and track version history of external code.


1 Answers

You must remove the gitlink entry in your index:

mv subfolder subfolder_tmp git submodule deinit subfolder git rm --cached subfolder mv subfolder_tmp subfolder git add subfolder 

Replace subfolder with the name of the folder for your submodule, and make sure to not add any trailing slash.

This is what I detail in "Remove a Git submodule?" and "un-submodule a git submodule".

The --cached option allows you to keep the subfolder content in your disk... except git submodule deinit would already have removed that content anyway. Hence the mv part.

You then can add and commit that subfolder.

like image 155
VonC Avatar answered Oct 05 '22 02:10

VonC