For one of my CS classes, I and a group are writing an application using a client/server architecture. I was curious what the best-practices would be for organizing the project in a Git repository. What I mean, is whether we should structure the directories like this:
ProjectDir/
Clients/
Client1/
# files...
Client2/
# files...
Server/
files....
and track everything on the same git branch, or whether we should create separate branches for the clients and the server, like:
on branch Server:
Project/
Server/
# files...
on branch Clients:
Project/
Client1/
# files...
Client2/
# files...
I don’t know if it makes much of a difference, but this will be the first project I undertake using git where the team consists of more than a couple people, and I want to make sure the pulls and merges are as simple as possible…
I’m not sure what you’re background is, but I’ve heard the same (similar) question asked over and over from people who are coming from central VCS like SVN. The fundamental difference between branches between SVN (centralized) and Git is that Git branches are very light and easy in comparison. After all, in Git, a branch is nothing more than a labeled commit (and the commit points to a commit that points to a commit, down the line until branches converge).
In SVN it’s common to host entirely separate projects in the same repository as separate sub-directories. These aren’t branches, but in SVN they look indistinguishable from branches (in SVN branches aren’t much more than sub-directories). However, you should understand what a branch is. A branch is two near-copies of the same piece of software that are being modified and developed in parallel. If you’re unsure if you have a branch, ask yourself if these branches will or could ever converge. If it would never make sense to have the branches converge, they’re probably not branches at all.
In you’re client-server program, I would suggest that your client & server aren’t branches. Rather, they’re separate repositories. If you value seeing their history separate, put them in separate repositories. If you want to see their history together, put them in the same repository but under separate directories.
An interesting feature of Git is that, due to it’s distributed nature, you could maintain the client and server in separate repositories and then later push them into the same repository as different branches. There would be little difference except being insane to try to understand.