5

I believe I have a very common problem that affects developers with multiple versions of their apps (in my case I have two: paid one and a free one). To manage both versions I use the same git project with 2 different branches: free and paid However my source code package names differ from each other (as expected), and with the java restrictions of having the directory names mapping to package names a problem arises: how to tell git to associate the files under a certain directory with each branch ?

Let me give you an example: I've two branches:

  1. master
  2. free

In master my source code is under com.zemariamm, however in the "free" branch the source code is under "com.zemariamm.free", how can I configure git to "tell him" that the source code under directory com.zemariamm (in branch master) maps to the source code under directory com.zemariamm.free (in branch free) ?

Thanks so much in advance, Ze

Leo
  • 37,640
  • 8
  • 75
  • 100
user361526
  • 3,333
  • 5
  • 25
  • 36
  • Can't you just share all the common code libraries, rather than having duplicates in the `free` and `paid` packages? – Eric Mar 06 '11 at 19:01
  • What do you mean? Having two different projects using parts of the source code ? Cheers :) – user361526 Mar 07 '11 at 19:22

2 Answers2

2

In theory, you wouldn't configure anything in Git:
If the content of com.zemariamm.free.MyClass is very similar to com.zemariamm.MyClass, Git should be able to link the history of the MyClass file between the two directories in the two different branches.

In particular, a merge from free to master should report new evolutions (lines added, modified or removed to MyClass) from the com.zemariamm.free.MyClass to the com.zemariamm.MyClass.

That only works if MyClass is "similar enough between the two branches though:
see "How does Git track history during a refactoring ?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Why not put just put both the free and paid code in one project, rather than using two projects?

Eric
  • 95,302
  • 53
  • 242
  • 374