I am developing a Client-Server application and I want to store both projects (Client and Server) on github the same github repo. I am on macosx. I created a local repository for the client side project with Eclipse git plugin and then I committed it to github. It worked fine.
Now I want to add to this Repo the server side project possibly inside a new subfolder. This part is developed on a different workspace than the client part. I tried to share the project using Eclipse, but it tells me there is no existing repo. I think this is because the two parts of the system are developed with different Eclipse IDEs.
I tried to create a new repo under the first one, but it became a great mess because github couldn't understand which was the master. I am using the GitHub client application to manage commits to the remote repo.
Someone can help me?
It probably doesn't answer your answer directly, but I think that this particular situation can be ruled with such feature of Git as submodules.
In this case you need to have two different repositories hosted somewhere, anyway. But with help of submodules you can tell Git that files of one repo should be located inside the directory tree of another one. Without causing the mess you described!
For example, assuming that you have your projects hosted as
github.com/user/Server repos. Go to the folder of
Client repository and do the following:
git submodule add [email protected]:user/Server.git src/server
This will clone the repo with given address into the folder you specified (
src/server in this example).
After that you have to commit changes. Although a lot of files were added, there will not be lots of changes in commit diff: there will be only a short record in special file saying that such repository now is a submodule. That is, files of
Server not actually stored in
Client repo, only the reference to them is stored. This is the power of git submodules.
Note that after that, when you clone your
Client repo somewhere else, its submodule will not be fetched by default. You have to use
git submodule update --init to initialize submodules.
Also note that the reference to
Server submodule points to a specific revision of it. After you made some changes to
Server repo you may want to go to
Client repo, navigate to directory of submodule (
src/server in this example) and do a simple
git pull and commit changes in
Client repo. Again, there will be no giant diff, only the new reference to submodule will be commited.
As an example of the repo with submodules you can check out my repo for Vim settings directory: it has many plugins inside its bundle folder and all of them are git submodules. GitHub shows them pretty well and allows easy one-click navigation to submodule repo if it is GitHub-hosted.
P.S. If this all has nothing in common with what you want, and you simply want a folder
Server to be added to repo
Client, you can just copy
Server to client and delete all traces of Git from
Server directory (if there were some) by deleting
.git inside it. Now you simply have one repo, commit all this lots of changes and go on. The drawback of this is complete loss of history of
Server repo — it is not a big pain at the initial phase of project.