I’ve never used version control before but I know it’s a good practice, so I decided to try it out. I like git, so I’m using that. I have a local Ubuntu server (separate box) where I do all my local development.
So I installed gitosis (following the Ubuntu community docs) and set up all that jazz.
My IDE is Eclipse, so I installed Eclipse EGit.
I have my Apache docroot shared with Samba so on my Windows PC (where I develop) I just load my projects into Eclipse and save them directly to the docroot (so like \webserver\www\projectname is my network share).
So my understand of Git is that I should create my repositories in /srv/gitosis/repositories. But when using EGit, it just saves the repository to /var/www/projectname/.git – is that normal? I’m a little confused as to how the whole thing should work.
Since you’re using a network share, you’re essentially operating directly on your server, so there’s no need for the whole gitosis thing.
In a normal source code repository situation, one would not have a network share with their centralized server. They would simply access it by SSH. In that case, gitosis is a solution they might use to provide certain users read/write access to the repository. They would push their updates to the server and pull down the updates of others.
However, in your case, you’re accessing the server directories from a network share, so as far as git is concerned, it’s the same as a local directory. All you need to do is code and commit. No pushing and pulling required.
However, operating directly on your web server’s content directory is probably not what you want. The reason is that as you make changes, switch branches, etc, you’ll end up putting your web server into a bad state. Think about it. You’ve got your fully functional website on the master branch. Then you checkout branch “my_website_2.0” which is not yet complete. Suddenly, all the files to which your web server points are in this half-completed state. Not good.
There are lots of solutions to this problem, some complex, some not. For example, you could setup a shared repository on the server to which to push your master branch, and then clone it to your web content directory. (Note this would all still be done with simple paths, because of your network share).
This page: Using git to manage website goes into detail on how to use git and have it automatically put shared changes in your webserver content directory, without having to do the clone on the server.
I’m sure if you google around, you’ll find additional solutions.
Here’s some additional detail, given your confusion below.
Egit (and git itself) works on local repositories. There is not a command to configure remote repositories. You push to and pull from remote repositories, and that’s about it. You’re expecting Egit to do things it doesn’t do.
Here’s what you need to do:
There. You now have a copy of the files in your bare, centralized repository. As stated earlier, now the task is to get those files from there into your web content directory. You could do that by cloning the central repository into your web content directory, or use a more sophisticated solution, like the one I linked or others you can find via google.