1

I'd like to do some versioning of some Android code.

I pushed the code (only the res and src directories) and now I want to pull it in some other package.

How can I manage that, given that the code in my git repository has it's source in src/com/some/package/ and I want to clone it and get the source in src/some/other/package/?

I'm aware of this question, but I can't see any answer that helps.

Community
  • 1
  • 1
jul
  • 36,404
  • 64
  • 191
  • 318
  • 2
    Have you tried turning the common code into a library project that you include? – jprofitt May 13 '13 at 18:27
  • If that's the only possibility, I'll try that. – jul May 13 '13 at 19:09
  • Depending on how project agnostic the code is, it should be a pretty simple way to keep it separated but available to both. – jprofitt May 13 '13 at 19:25
  • It's something similar to what's described in http://stackoverflow.com/q/5212597/326849: two versions with different features, but lots of code in common. – jul May 13 '13 at 19:27
  • You'd have to make an Android Library Project, rather than something that is specific to git. But you could then put that project into a git repo, and have your two other projects include it. So you'd end up with three projects (and repos) in total. – jprofitt May 13 '13 at 20:20
  • Ok, it seems to be the best solution. Can you write it as an answer, so that I can accept it? – jul May 14 '13 at 09:57

1 Answers1

0

What you can do as an alternative to directly managing it with git, is to separate the common code into its own Android Library Project. Then you would be able to add that library to the other two projects, giving you access to the same code base.

This would have you end up with three projects, and three repositories. Two of each for the separate projects, and one of each for the library project.

One thing to be aware of, however, is that if there is specific code for one project inside of the library, it will also affect the other project. Some of this could be handled by subclassing and overriding methods/properties as needed. Another way around this, as suggested by jul, would be to have branches for each project.

A nice benefit of doing it this way is that if you make a bug fix in the library that you found while working on one project, you'll be able to get that in the other for practically free.

jprofitt
  • 10,874
  • 4
  • 36
  • 46