Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 ?

question from:https://stackoverflow.com/questions/26752481/remove-git-submodule-but-keep-files

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.4k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...