views:

185

answers:

7

Hello,

I have been hearing a lot about the advantages of using a version control system and would like to try one. I was doing freelance web development in PHP for the past 2 years, two months back I hired two more programmer to help me. I will be hiring one more person soon. We maintain 4 websites, all of which are my own, which are continuously being edited by one of us. I learned PHP by myself and have never worked in any other firms. Hence I am new to version control, unit testing and all.

Currently, we have development servers on our workstations. When we edit a particular section of a site, we download the code for that particular section (say /news/ or /movies/ or /wallpapers/ ) from the production server to the dev server, makes the changes locally and uploads to the production server (no code review / testing). Because of this, our dev server is always out of date from our prod server. Occasionally, this also create problem when one of us forgets to download the latest copy from prod and overwrites the last change. I know this is very very foolish, but currently our prod server is the only copy that has all the updates and latest changes.

Can anyone please suggest which is the best version control system for me? I am more interested in distributed version control, since we don't have a central backup for all our code. I read about Mercurial and Git and found that Mercurial is used in several large open source projects by Mozilla, Sun, Symbian etc. So which one do you think is better for me? Not only version control, if there are any other package that I can use to make my current setup better, please mention that too :)

Thanks and Regards, Vinod Mohan

+1  A: 

You can use SVN, Git, Mercurial.

The biggest challenge is having everyone be disciplined in using version control and not getting lazy.

Kevin
This was the main reason I haven't thought of using this before. But now I understand that the advantages outperforms the inconvenience.
Vinod Mohan
It's never occurred to me that people would fail to be disciplined in version control, because it saves everybody so much time if people do it. But then it's been years since I even considered developing without version control.
Benson
It happens. Especially if people aren't used to working with code versioning, it will happen at some point.
Kevin
+1  A: 

Version control is an incredible tool even when you're working alone, and when you are working with someone else it's indispensable. I would recommend using git. It's very fast, has a really great set of available tools, and of course has github.com. Mercurial is basically just as good as git, but it runs a little slower and doesn't have github.

For why to use git, please read http://whygitisbetterthanx.com/

Here's a nice-looking tutorial on getting started with git: http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html

Benson
Since I am not sure how this is going to turn out, I am more interested in a free setup. If Git is DVCS, why do we need a project hosting server like Github.com?
Vinod Mohan
Github is free for projects you want to do out in the open. You can use git without github, and it's great, but github adds a lot of value. I thought the github docs might help get you started.
Benson
Bitbucket is the same as Github, and it gives you a free private repository. I wouldn't consider Github to be a good point of Git, or any other service. There are services that support all three like CodeBaseHQ or a much better one than the ones I mentioned so far: Kiln (for Mercurial though). Repository hosting services are everywhere.
iconiK
@Vinod: If you want to have a nice central place where everyone can pull and push from, you need hosting. It makes synchronization between you easier, as you don't have to get everyone to run a server so you can pull/push from them.
iconiK
@iconiK Github is more than just project hosting, it's a community of users. It encourages creating small projects to share handy bits of code. Everyone knows you don't *need* a hosted solution for DVCS; it's about the features they add, not the free hosting. If your code is private there's a good chance you don't want it sitting around on someone else's servers anyway.
Benson
+2  A: 

It sounds like Git can accomplish your goals quite well. As it's distributed, it's excellent for working locally since you can perform most operations (commit, revert, diff, patch) without connecting to a central server. You can also avoid that ugly moment of someone pushing new code to production while someone else is working on it, and then having the complicated task of merging those two versions of the code together (git provides a useful tool for doing this called rebase).

You noted there's some big projects using Hg (Mercurial), but there's some pretty big ones using Git, like the Linux Kernel, X.org, Android and Debian.

I use git for all my sites: it's lightning fast, efficient, and easy to use.


Edit: If you want to get into using Git, I'd recommend doing some reading before jumping right in. Starting off on the wrong foot can have some terrible implications later on. If you follow an Agile Workflow, you might want to check this out. Here's a website I learned most of my Git know-how from.

Zack
Thanks, Zack. Do I need a central server for using Git? If needed, can I just turn one of my dev servers into a central server?
Vinod Mohan
You aren't required to have one, but you do need one, in the sense that it will really make your life easier.
Benson
You don't need one, but it's a good idea to have one. Hypothetically, you could have each developer add every other developer as a remote location and share work that way, but it would be quite a nightmare. Git is very lightweight and can run behind pre-existing SSH authentication.
Zack
I second git: http://whygitisbetterthanx.com/
Juraj Blahunka
They should have, "because using git is more fun than the actual code you're writing" listed on there, me thinks.
Zack
A: 

Thanks a lot for the quick answers. So are everyone for Git? No Hg supporters? :)

Vinod Mohan
A: 

Definitely Mercurial. Although you can use either Git or SVN, Mercurial is better for two reasons:

  1. Vs Git: Good integration with Windows.
  2. Vs SVN: It's distributed.

If you don't want to run yourself a Mercurial server (which is pretty easy anyway), there are many services available. Kiln + FogBugz is an EXCELLENT combination. There's also CodeBaseHQ (also supports Git and SVN), Bitbucket, and many more.

Before you jump onto it I strongly recommend you read at least Joel Spolsky's tutorial, but I strongly recommend you also read Mercurial: The Definitive Guide.

iconiK
Thanks. I too just read ( http://www.straw-dogs.co.uk/11/16/mercurial-vs-git/ ) that Git has poor windows support. Windows support is important for me, because everyone are using Windows, other than myself.Ease of use is another important factor for me. Because I will have a hard time teaching others how to use the system. Which one is more easier from a user's point of view. Setting up the system is my job, and I don't mind it being a bit complicated.
Vinod Mohan
@Vinod, Git was designed for Linux so it's no surprise Linux is treated as first class, OS X is doing fine as it's very similar and Windows is a second-class citizen. The onlystable way to run Git is under Cygwin; there is a port under MinGW, but I find it pretty slow and unstable.
iconiK
@Vinod: Subversion integration in Windows is excellent: TortoiseSVN is as good as it gets for Explorer, VisualSVN is an extremely good tool for Visual Studio and practically all IDEs have SVN integration. THe tools for Mercurial are kind of raw: TortoiseHG is usable, but not great; VisualHG, I haven't used it, can't say much. Eclipse-based IDEs have good integration with Mercurial though. However, the command-line interface is pretty easy to use; see this cheat sheet: http://goo.gl/iQc4
iconiK
Git has come a long way on Windows since 2008, when that post was made. Cygwin is **not** the only way to run Git, Git runs natively with a GUI or from CLI as msysgit, which can be found on Google Code. It also runs in Eclipse, if you use that.
Zack
@Zack, I know that. I use msysgit myself. My comments are based on my experience, not on what I read on a website.
iconiK
As are mine, I've worked on many Windows XP, Vista and 7 computers, and msysgit works just as well as in Linux.
Zack
Your attacks on git are unwarranted, and you don't address a number of reasons git is superior to hg. The concerns I have are best explained by this website: http://whygitisbetterthanx.com/
Benson
I suppose the down-voters are Hg haters? O.o
iconiK
The down votes are probably from people who don't like slander, myself included.
Zack
A: 

I am sorry, I had no intention of starting a DVCS holy war. I am going to try Git.

Vinod Mohan
A: 

Yes, version control will help. To get started, I see two important issues for you:

  • hosted or self-managed? Do you want to host this yourself on a server, or want a service to take care of it for you? There are reasons to go either way, but if you're not that into managing the server look for a hosted option.

  • SVN or Git There are others, but these are the top open source contenders.

Pros and Cons (my opinion):

SVN: Good tutorials and fairly easy to get up-to-speed with. The training requirement is small (I've done a bit of it). SVN works really well with a co-located team, lots of projects, etc. With a limited number of branches (you may not need any), it is solid. There are plenty of integrations with other tools.

Git: Getting started can be a little rougher than with SVN. Some of the docs are good, but lots are geared assume a rather thorough understanding of the internals. Once you get the hang of it, it has great flexibility, but I've seen almost everyone who has started with it really stumble when beginning. Even after working with it for months, people debate the best patterns to use. It's really sweet for 1-person projects (where you want to track history), and for distributed projects like GitHub. I use Git even for small co-located teams, because I enjoy the speed and flexibility.

Given what you say about your team, though, I'd probably recommend trying SVN. There will be better resources to help you get going, and you'll be less likely to get frustrated with it.

Hope this helps.

ndp