Accessing git submodule in Android Studio

I am just starting to use source control for my own project and now I want to add Joda-Time. I want to add it as a submodule, so I went into terminal and ran:

git submodule add https://github.com/JodaOrg/joda-time.git

      

and it downloaded all files successfully. Then I ran:

git submodule init

      

And got nothing.

git submodule status

      

returns

b9fe534c7f5876eced6494a6d6c1deaf2528a579 joda-time (v2.7-17-gb9fe534)

      

I checked the root of the projects and I can see the new joda-time directory and its source. But how do I access the library in my project? Did I miss a step?

+3


source to share


3 answers


I have been unable to answer the answers provided. As I continued to search the web for a clue, I came across Joda-Time-Android , so I removed the original Joda-Time submodule and tried again with a new one. It works! He added himself to my project and is ready to rock!



At the time I was still looking for the original issue, Joda-Time does not contain a build.gradle file, but Joda-Time-Android - I think that was the problem.

0


source


Try with git submodule update --init

. This will allow you to do git submodule init

it git submodule update

in one step. Note that you only need to add the parameter --init

once.

Quoting from doc :

Update

Update the registered submodules so that the superproject is supposed to clone missing submodules and update the working submodule tree.



On the other hand, git init

in itself is simply

copying submodule names and URLs from [your] .gitmodules [file] to [your local] .git / config [folder].

Once you do this, you will notice that your submodule is in a DETACHED state. You can just checkout any existing branch from there, say git checkout master

to checkout the branch up the tag master

.

+3


source


You missed git submodule update

. From the docs:

Update the registered submodules so that the superproject is supposed to clone missing submodules and update the working submodule tree.

You can also do this with an option --init

that will do for you git submodule init

.

+2


source







All Articles