9

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 :)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Joyce Babu
  • 19,602
  • 13
  • 62
  • 97
  • What platform do you develop on? I'd love to find you an appropriate git tutorial, but I need to know if you're on windows, osx, etc. – Benson May 02 '10 at 06:14
  • I am using OSX, others are using Windows and our prod server is Cent OS – Joyce Babu May 02 '10 at 06:16
  • 2
    Git can run on all of those platforms, there's GUI tools for it for each (though I'd recommend using command-line) as well as a pretty stable plugin for Eclipse for it. Since you're using OSX, I'm assuming you use TextMate (and if you don't, it's very, *very*, **VERY** worth checking out), and there's a bundle available for it. – Zack May 02 '10 at 06:34
  • Git and Mercurial seem like a good choices for you. You can also check out PHPStorm by Jetbrains. It's an IDE which integrates all the version control features right into the interface. – miki725 Mar 18 '11 at 21:33

6 Answers6

3

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
  • 2,274
  • 3
  • 24
  • 26
  • 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? – Joyce Babu May 02 '10 at 06:25
  • You aren't required to have one, but you do need one, in the sense that it will really make your life easier. – Benson May 02 '10 at 06:27
  • 1
    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 May 02 '10 at 06:30
  • I second git: http://whygitisbetterthanx.com/ – Juraj Blahunka May 03 '10 at 09:43
  • They should have, "because using git is more fun than the actual code you're writing" listed on there, me thinks. – Zack May 03 '10 at 09:46
2

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
  • 22,457
  • 2
  • 40
  • 49
  • 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? – Joyce Babu May 02 '10 at 06:20
  • 2
    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 May 02 '10 at 06:26
  • 1
    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. – CMircea May 02 '10 at 06:59
  • @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. – CMircea May 02 '10 at 07:00
  • @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 May 02 '10 at 21:05
1

You can use SVN, Git, Mercurial.

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

Kevin
  • 13,153
  • 11
  • 60
  • 87
  • This was the main reason I haven't thought of using this before. But now I understand that the advantages outperforms the inconvenience. – Joyce Babu May 02 '10 at 06:17
  • 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 May 02 '10 at 21:11
  • It happens. Especially if people aren't used to working with code versioning, it will happen at some point. – Kevin May 02 '10 at 22:11
1

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.

CMircea
  • 3,543
  • 2
  • 36
  • 58
  • 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. – Joyce Babu May 02 '10 at 06:48
  • @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. – CMircea May 02 '10 at 06:54
  • @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 – CMircea May 02 '10 at 06:56
  • 1
    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 May 02 '10 at 07:27
  • @Zack, I know that. I use msysgit myself. My comments are based on my experience, not on what I read on a website. – CMircea May 02 '10 at 09:08
  • As are mine, I've worked on many Windows XP, Vista and 7 computers, and msysgit works just as well as in Linux. – Zack May 02 '10 at 20:05
  • 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 May 02 '10 at 21:03
  • I suppose the down-voters are Hg haters? O.o – CMircea May 02 '10 at 21:03
  • The down votes are probably from people who don't like slander, myself included. – Zack May 03 '10 at 06:56
0

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

0

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
  • 21,546
  • 5
  • 36
  • 52