Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push submodule to github using android studio?

I cloned an android project from github. I made changes after cloning and pushed it to the main repository from android studio. Everything worked fine but when I add an external library in my project I can't push it. I think its a sub module. Could anyone tell me how to push external library as a sub module from android studio?

like image 588
androidcodehunter Avatar asked Sep 30 '22 17:09

androidcodehunter


2 Answers

After searching internet I found a simple way to do it. To add a sub-module we need to run this command

git submodule add LIBRARY_URL

and to init the sub module locally

git submodule update --init --recursive

like image 140
androidcodehunter Avatar answered Oct 04 '22 17:10

androidcodehunter


If it is a submodule, you should be able to list the gitlink entry, special mode 160000

$ git ls-tree HEAD mysubmodule 
 160000 commit c0f065504bb0e8cfa2b107e975bb9dc5a34b0398  mysubmodule 

It should also be recorded in your main repo/.gitmodules file.

In that case, all you need to do is add and commit that entry, and push it.

If it is not, then remove that folder, and add it again as a submodule through command-line (instead of Eclipse/Egit)

git submodule add /url/of/library/repo mysubmodule
git add mysubmodule   # no trailing / here)
git commit -m "Add a submodule"
git push toAndroidRemoteRepo
like image 34
VonC Avatar answered Oct 04 '22 16:10

VonC