2

I've been developing an Android Wear project ("RefWatch") using Android Studio for about 18 months. I noticed about 6 months in that the git repositories for the project are actually in two directories: /Users/<name>/AndroidStudioProjects/RefWatch/mobile (the mobile module) AND /Users/<name>/AndroidStudioProjects/RefWatch (the wear module and everything else)

I don't know whether this was an accident when I created the Android Studio Project, but Android Studio seems to do an ok job of commits/checkouts to the separate repositories.

Where I run into trouble is:

  • I want to branch my code; this always seems to create a detached HEAD
  • If I want to use command line commands I seem to have to browse each repository separately
  • I want to push everything to BitBucket or some other remote

So, questions:

  1. Is this "two .git" directories actually normal or ok? Is it designed this way?
  2. Is there a way of merging the two .git repositories to simplify my life?
Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
Opus1217
  • 723
  • 4
  • 17

1 Answers1

2

The mobile module was likely added as a Git Submodule. This is completely reasonable, and may or may not be what you actually want to do.

If you're using a submodule, you will have to manage each repository separately, which includes browsing the history, committing, pushing to a remote, or running other Git commands.

If you want the mobile module to have a separate release cycle from the main project, and/or if you will be reusing it in other projects, then you should leave it as a submodule. Otherwise, it should be fine to merge the repos.

To merge the the submodule into the main repo, do:

mv mobile mobile-tmp
git submodule deinit mobile
git rm mobile
mv mobile-tmp mobile
git add mobile

(From VonC's answer to "un-submodule a git submodule".)

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67