How to include a git submodule into a project?

So I have a git repository for a few related Java classes with a folder structure similar to this:

mylib/LICENSE  
mylib/README  
mylib/src/file1.java  
mylib/src/file2.java  
mylib/test/tester.java  
...

Now, I’m creating an Android app in Eclipse with the traditional folder structure like:

  • Error to Import Github project into Eclipse?
  • Using Git With Eclipse Remote Systems Explorer
  • Android Studio, how to add my own git repository as a library project(sub module)?
  • Subclipse svn:ignore
  • cross platform git: possible strategies to handle platform specific files
  • How to make a separate Eclipse project out of a subfolder under Git source-control
  • repo/AndroidManifest.xml  
    repo/bin/*****  
    repo/res/*****  
    repo/src/com/mysite/project/activity1.java  
    ...
    

    Now, I’d like to add the java classes to my android project in the folder:

    repo/src/com/mysite/mylib/file1.java
    

    However, if I add it as a git submodule, they are saved to the path:

    repo/src/com/mysite/mylib/src/file1.java
    

    Also, included is the tester.java, and some other files I don’t want in the Android project.

    What is the best way to resolve this? Should I just leave the path as com/mysite/mylib/src/file1.java? Or should I modify the repo and move the files from mylib/src up into mylib and delete the files I don’t want?

  • Removing history from git - git command fails
  • Git commad alias pipe for powershell
  • Symbolically linking files inside a git subdirectory
  • Multiple coders on the same source
  • gitignore file for SQL Server project: SSIS / SSAS / SSRS?
  • git push error: RPC failed; result=22, HTTP code = 403
  • One Solution collect form web for “How to include a git submodule into a project?”

    The simplest way would be to:

    • keep your original (non-Android) repo separate
    • add that original repo ‘src‘ folder as a source folder of your Android Eclipse project (an Eclipse project can defined several src folders, from various origin)

    That will sidestep the “submodule” issue entirely, and allow you to select from your original project only the files you need for your Eclipse Android project.

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