Accessing git submodule in Android Studio

I’m just starting out using 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 the terminal and executed:

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

and it downloaded all the files successfully. Then I ran:

  • Adding remote git link to file header Intellij Idea
  • Android Studio git check in author name
  • New Git branch option in Android Studio disabled
  • How to delete a repository and add a new one in Android studio?
  • Git in android studio commit error
  • Creating Branches in Android Studio
  • git submodule init
    

    And got nothing back.

    git submodule status
    

    returns

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

    I checked my projects root directory and I see the new joda-time directory and it’s source. But now how do I access the library in my project? Did I miss a step?

  • Git Checkout ignore directory
  • How do `git merge B --ff` (when successful) and `git reset B --hard` differ?
  • Git - Difference between amend and squash commands
  • Can not create a local and remote branch (tracking) at the same time
  • Why is git log --cherry-pick not removing equivalent commits?
  • Synchronize git workspace with another folder
  • 3 Solutions collect form web for “Accessing git submodule in Android Studio”

    Try with git submodule update --init. This will allow you to do git submodule init and git submodule update in one step. Note that you only need to add the --init option once.

    Quoting from the doc:

    update

    Update the registered submodules to match what the superproject
    expects by cloning missing submodules and updating the working
    tree of the submodules.

    On the other hand, git init by itself simply

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

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

    You missed git submodule update. From the docs:

    Update the registered submodules to match what the superproject
    expects by cloning missing submodules and updating the working tree of
    the submodules.

    You can also do it with the --init option, which will do the git submodule init for you.

    I wasn’t able to have any luck with the answers provided. As I kept searching the internet for a hint of help I stumbled across Joda-Time-Android so I removed the original Joda-Time submodule and tried again with the new. It works! It added itself to my project and it’s ready to rock!

    During the time I was still troubleshooting the original issue Joda-Time doesn’t include a build.gradle file but Joda-Time-Android does – I think that was the problem.

    Git Baby is a git and github fan, let's start git clone.