views:

66

answers:

4

I am about to take the plunge and start using Git for actual projects that others use!

So far I've used Git on some basic projects and played around with Github for some university projects, but now me and some others will be working on multiple projects. As a result we'll be hosting Git on a remote server and to be honest it'd be great if we could just get started on a tried-and-tested method of using Git for our needs.

At first we thought of hosting the Git master on the server, a la...

Site: /home/vhosts/domain/htdocs

Git: /home/git/domain.git

This sounds like it'd work, but I'm worried about hosting a repository on the server the main website is running from in case it goes down or if we lose data, as we'd be left with our local copies. I'd like to have it all running on a development server, but some think that it is overkill and some thing that logistically it could be a nightmare.

To be fair, we're all recent graduates and have only basic experience with source control on hobby projects and solely on final-year CS projects, with the popular option at that time being subversion. One of the reasons we chose Git was through word-of-mouth from other developers and through recommendations of friends who use it extensively at work.

To clarify, we will be working on multiple, hosted projects and would like to deploy using Git. What we're stuck on is on the best way to handle this. There will be around three of us working on separate machines at any one time with a live server and (hopefully) a development server to test stuff on.

For those who are dealing primarily with web applications, how do you use Git to deploy your working code to the server? Are we barking up the wrong tree for our needs? Any tips you can give a Git novice?

+4  A: 

The thing you need to understand is that all Git repositories are, essentially, "local".

When you clone a repository using git clone, you are getting the entire repository with all of its changes and logs. If you lost the remote repository, your local clone can pick up right where the remote one left off.

In addition, you could have multiple remote repositories attached to your local repository: for instance, when I'm working on a site, I'll have my own local repository, and a remote repository on both the development server and the production server. Then, it's just a matter of pulling and pushing to the correct one depending on context.

And those remote repositories are nothing special: they're just directories containing the same things on my computer.

So the only thing you need to worry about is making sure your remote repositories are accessible by every one on your team: if you don't have any other place to put it, the server you have the site on is fine.

Mark Trapp
+2  A: 

If you want to work with a (or different) team(s), you should look at Gitosis: it is a simple way to manage multiple Git projects with custom access rights (read/write) by user and by project.

A Gitosis tutorial: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

Another solution is Gitolite, a Gitosis evolution.

Benoit Courtine
+1  A: 

I actually wrote a blog post about the procedure I use to deploy my website from a local computer to a staging server and then the live site, since it's somewhat complicated. The writeup might be useful to you if you want to use a two-tier distribution architecture (staging server and then live server). If you don't want to use a staging server, you can configure your local computer to push directly to the live site, and that's way simpler. Of course that setup would still allow you to test on your local computer.

Other than that, I would echo what Mark Trapp said about the decentralized nature of git. There's no problem with putting your central repository on the web server, since your local copy contains everything you need to keep working and to reconstruct another central repository if necessary.

David Zaslavsky
A: 

We use gitosis to manage multiple repositories with multiple users: http://pkill.info/b/1432/setting-up-git-server-using-gitosis/

Previously we use git through SSH connection. That will make every one is the administrator. So we move to gitosis. We can control who can write to one repository and who can read one repository. And we can have several administrators. We can also set up email notification scheme. We are happy with it by now.

Zhiqiang Ma