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.

6
  • 2
    Have you tried turning the common code into a library project that you include? Commented May 13, 2013 at 18:27
  • If that's the only possibility, I'll try that. Commented May 13, 2013 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. Commented May 13, 2013 at 19:25
  • It's something similar to what's described in stackoverflow.com/q/5212597/326849: two versions with different features, but lots of code in common. Commented May 13, 2013 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. Commented May 13, 2013 at 20:20

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

About the specific code for one project, I can have several branches.
Very true! I'll update the answer to include your suggestions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.