1

Imagine mobile application that is planned to be implemented for both iOS and Android. Development was started from the iOS version only and now the time has come to start with Android one. iOS application's code is stored at its' own Git repository that named after the apps name, e.g. "MYApp". Now I would like to create one common repository for both iOS and Android applications and name it again after application's name: "MYApp".

It is not a problem at first glance. Just create repository, create 2 subfolders there and start working.

But. I would like that Android developer could work only with his folder and iOS developer only with his one too and both of them could see only their own folders related history (log).

I worked with SVN previously. Usually I created subfolders and you could checkout any of them to work only with this subfolder. History was also filtered to your scope.

I'm stuck with implementing the same under Git. Please, help me to find right direction.


I will sum up solutions suggested.

  1. Use branching for different platforms. I don't think that it is good idea, because branches used for another purpose. It seems to me very "jacky".
  2. Use submodules. Just create as many repos as platforms you are targeting to, name them "MYApp-iOS", "MyApp-Android", etc. and finally end up with "master" repo, that could be names as "MYApp" (without any suffixes). Then add all related repos to "master" one with git submodules feature.
  3. Use git slave. Investigating...

Please, feel free to edit this list to brainstorm the problem.

nickolay
  • 3,643
  • 3
  • 32
  • 40
  • You could try with two [branches](http://git-scm.com/book/en/Git-Branching) but this really doesn't sound like a good idea. Do you have a really really good reason not to use two separate repositories? – Rok Jarc Nov 10 '13 at 14:39
  • A question that is kind of related to your problem: http://stackoverflow.com/q/466303/653513 – Rok Jarc Nov 10 '13 at 14:42
  • 2
    Wouldn't this be a nice case for using submodules? Just have the two repos and use submodules for the main repo with both projects in them – Hugo Tunius Nov 10 '13 at 14:45
  • Yes, this seems legit - especially if any part of code can be shared. But still this also suggests using two repos - which is probably the right way to go. – Rok Jarc Nov 10 '13 at 14:50
  • thanks, guys! I'm thinking in the same way just curious why git does not allow to store logically related code in the same place as svn does? – nickolay Nov 10 '13 at 15:06

1 Answers1

1

There is a way to keep to kind-of-related separate projects in a same git repository utilising git branching.

But keep in mind that that is not why branching was implemented into git. One of its uses would be development of a radical new functionality to your app that might not see the release any time soon for example.

On the end: it is a matter of opinion. If you are prepared to administrate a more complex repository just to keep both codes on the same place - you can.

I would definetly make two separate repositories though. Couple of opinions on this topic can also be found here on SO: Git branches with completely different content

EDIT:

gitslave seems to tackle your problem. You might want to give it a try.

Community
  • 1
  • 1
Rok Jarc
  • 18,765
  • 9
  • 69
  • 124
  • Thanks! I will not use branches as they are implemented for the other purpose. I'm trying to find some legit way to keep logically connected code in the same place. I consider that code of the same application targeted to different platforms is logically close enough to store it as subfolders of the same repository. It is very strange that I cannot implement this simple idea in git. I find git very convenient and moved from svn with no regrets, but this situation made me confused. – nickolay Nov 10 '13 at 15:12
  • 1
    You might want to take a look at [gitslave](http://gitslave.sourceforge.net/). I'm not familiar with it but it _creates a group of related repositories—a superproject repository and a number of slave repositories_. – Rok Jarc Nov 10 '13 at 15:17
  • 1
    Will give it a try and post about progress. Thanks. – nickolay Nov 10 '13 at 15:19
  • 1
    Hi @DaddyM, can you please tell me what strategy did you use? Did gitSlave worked for you, or something else? – Muhammad Mehdi Raza Mar 01 '17 at 08:32
  • Hi @MuhammadMehdiRaza, sure. The easiest and the best way to do such things is to have separate git repository for each app for each platform. So in case you are developing an app for iOS and Android you should end up with two repositories - one for iOS and the another for Android code. Hope this helps. – nickolay Mar 01 '17 at 17:22