Join 3,561 readers in helping fund MetaFilter (Hide)


Loading multiple xCode projects to one GitHub repository?
September 27, 2012 2:11 PM   Subscribe

Loading multiple xCode projects to one GitHub repository?

I am a complete newbie to iOS development, xCode, Git, GitHub - and Macs, for that matter. I am also a student, not a professional developer (and haven't posted this to stackoverflow for fear of ridicule). Google isn't helping, maybe because I don't know the right terminology or am just missing something very rudimentary - so rudimentary that it's not been discussed online...

I am using Git through the xCode GUI, not via command line.

I am trying to push multiple iOS projects up to a single GitHub respository. This repository has other collaborators. We have all been experimenting and getting to know iOS development, and we each have several little projects with local git respositories created on our local machines. For example, I have a project going where I play with switching amongst views, and another one where I'm experimenting with controls. I now want us to go ahead and push these individual projects to a repository I created on GitHub called 'Play'. I want it to be a sandbox where we try stuff out before we rev up to creating our app.

My problem is this: I can push one project up without a hitch. But when I try to push another project up to the repository, it wants me to pull the project that's already in the repo first. I don't want to do that. I want my projects to remain separate on my local machine.

I think my problem is that I'm essentially wanting Git to add a repository to a repository, which doesn't make sense and which it thus refuses to do. So, how do I get all these individual projects into one repository? I would really like to do this the 'right' way, rather than via some kind of workaround. And the most foolproof way, if possible.

I have experience with .NET projects in Team Foundation Server, if you want to/can draw analogies.

Thank you very kindly for your help. I've been at this for several hours and frankly, am going nuts.
posted by kitcat to Technology (11 answers total) 1 user marked this as a favorite
 
Can you not move your individual projects into a common folder like so?

GroupFolder/ProjectA
GroupFolder/ProjectB
GroupFolder/ProjectC
...

and then commit and push GroupFolder?
posted by DetriusXii at 2:16 PM on September 27, 2012


DetriusXii:

er..so you are suggesting that I make a directory (via the mac OS) and push and pull that directory? If I do that, I will not be able to do pushes from xCode, correct? And every time I alter some code, I will have to copy the altered project files to that folder and then push the changes up?
posted by kitcat at 2:28 PM on September 27, 2012


I'm not sure with xCode, but you could still use the command line tools available to pull and push. I forget the Git client available for Mac OS, but you can type the commands

cd GroupFolder
git commit -a -m "Here is my commit message"
git push

on a command line when you're ready to push.

I would doubt that xCode would give you the option to push individual projects into a GIT repository as it likely makes some assumptions between the relationship of projects and repositories. I usually keep a terminal window open when I develop just for Git commits. I didn't use xCode to manage my Git repositories when I was in the iPhone development world.
posted by DetriusXii at 2:38 PM on September 27, 2012


Caveat: I don't use XCode, so I may be making incorrect assumptions about it

What you want to do is possible, but there's some potential complications. The ways I can see doing it (in order of how close they are to what you're asking, and, coincidentally, reverse order of ease) are:

1. Create a a new git repository called "Play" and add your other git repositories to it as submodules. This is complicated and error-prone even for a git whiz. I really can't recommend it.

2. Do what DetriusXii suggested and put them all in a folder, then check in that folder. You've already identified the problem there -- you loose the XCode git integration. This is actually a pretty decent option, since you can just use Github's app instead of the XCode integration.

3. Give up on putting it all in one repo. This is what I'd recommend, since it means you're not fighting your tools.

The best choice will probably depend on why you don't want to put them in separate repos. Could you elaborate? I'd be happy to expand further on whatever option sounds best.
posted by duien at 2:38 PM on September 27, 2012


I guess the reason I don't want to put them in separate repos is that a) I only have so many repos available with my account (these are private since we are eventually developing a commercial app) and b) it just seems dumb to have a repo for "kitcat's crappy experiment with creating pickers programmatically".
posted by kitcat at 2:46 PM on September 27, 2012


I guess the reason I don't want to put them in separate repos is that a) I only have so many repos available with my account (these are private since we are eventually developing a commercial app)

If you ask GitHub nicely and really can't afford the monthly charge for more private repos, they may help you out, although by policy they might not do this for commercial projects. (I'm not entirely sure on that point.)

and b) it just seems dumb to have a repo for "kitcat's crappy experiment with creating pickers programmatically".

One of the advantages of a DVCS like git and GitHub as a hosting platform is that both are very well-suited to small, one-off repositories. I pretty much start one for anything bigger than a one-liner that isn't already part of some other project. I'd encourage this approach.

I will echo the sentiment that submodules should be avoided generally. There are narrow use cases where they're really the only good fit, but the submodule stuff is utterly miserable to deal with and is just full of sharp edges.
posted by brennen at 3:07 PM on September 27, 2012


Don't fear ridicule on StackOverflow. Your question is valid.
posted by jeffamaphone at 3:10 PM on September 27, 2012


Thank you so much for your help. I think that the first solution put out by DetriusXii and the "Give up, use separate repos" are equally good solutions. I may just try both and see which works out better for us. I'm working on adding a folder containing multiple projects and it's going ok, but I've run up against an error trying to pull from the master branch (Play/master does not appear to be a git repository). If this takes me too much time to sort out, I may go back to the xCode integration/multiple repositories solution.

It's nice to know that my question was valid and that there are indeed solutions! Thanks again.
posted by kitcat at 3:22 PM on September 27, 2012


You may want to look into BitBucket also. They offer free private repositories with some restrictions on the amount of users that can be added to the repository. They support both Mercurial and Git as version control systems.
posted by DetriusXii at 3:41 PM on September 27, 2012


You know know, I even wonder whether DropBox might be a better option for the sandbox projects. We could wait until real development starts before using GitHub or what have you.
posted by kitcat at 4:05 PM on September 27, 2012


I'd start using Git right away if I were you (instead of Dropbox). A big part of what you're going to do later will involve source code management and you'd be better off making mistakes and fixing them now on a less important project !

Concerning your project, I'd do what DetriusXii told you in the first answer and use Github's app or even the command line to manage your Git operations. It's not that hard and you'll learn about Git at the same time.
posted by agregoire at 6:09 PM on September 27, 2012


« Older Looking for a place in NYC whe...   |  How can I make my healthy meal... Newer »
This thread is closed to new comments.