Entries in subversion (1)

Monday
Aug012011

5 Reasons why to switch to Git

I'm going to predict that 2010 is the year where Git becomes the defacto version control for most open source projects. I also think Git will see a wide spread use from corporations but not as fast because of the slow adoption of anything new. If you've not heard of Git, I strongly suggest to check it out. I was skeptical myself. I had just moved over to Subversion a few years ago from CVS and that from Visual Source Safe. The last thing I wanted to do was learn another version control and SVN seemed to do the job. That was until over the winter break I was looking for a project on GitHub and needed to use Git to download the source code. I instantly fell in love with it. All the things I loved about SVN it seemed to do better and all the problems of SVN seem to have been solved! Reason's why to start using Git

#1 Local Repository features

The one advantage Git has over other repositories is how much you can actually do on the local version. Besides doing a fetch, push or a pull, most commands are done locally. The ability to do a diff locally without hitting the server can save a ton of time.

 

One feature I like is creating local branches that I can do all my work on and not have the fear of messing up the remote repository with my changes because I committed the changes. Now I can work locally, make as many commits as I need to and if I have to rollback I can do so with no worries. Once I have the version that is what I feel is good for everyone on the team to use, I can simply commit to the remote repository.

#2 The staging area

The staging area is a great idea. Sometimes you have code that you're not quiet sure you want to commit but you want to store it in a place while you continue to work on the file. If the changes made in working directory have gone 180 on you still have the code in the staging area. However, If satisfied with the new code, simply add the code to the staging area again. Then use the commit command and the code is moved from staging to the local repository.

The main advantage of using the staging area is that when committing to the repository only the files ready to be committed are actually added. This avoids accidentally sending files in the working directory that may not be ready. Git does not force the developer to have to use the staging feature. Directly going from the working directory to the local repository can be done by adding the -a option when issuing the commit command. However, remember that using the -a argument of the commit command, sends all the modified files that were added previously to the local repository. This has been a hard habit to break for myself since I'm so used to the way SVN handles commits, that I was using the commit command with the -a option. Now what I know of the advantages of staging, I can avoid these problems I've had in the past.

#3 Local Branching is super easy

Local branching allows for the developer to create as many branches without having to have them stored on the the remote repository! Keep one(1) branch for production, one (1) for development where to do all work in, and then other branches for experimental work.

The beauty is that switching between branches is as quick as typing the branch name. Simply type git checkout <Your Branch Name> and the working directory has switched over to the selected branch. It's very easy to then merge changes from each branch. Again this is all done locally. These branches can stay local or any branch can be added to the remote repository.

#4 Cloning a remote Repository gives you the entire repository!

When cloning from remote repository, a complete copy is added to the local repository, not the current version like how Subversion handles it. This alone has many advantages. If working offline because the internet connection is down, or on a train or plane, the entire repository is still available for all the features normally found only when making calls back to the remote repository. The ability to continue to make commits when offline is a huge deal! Commit the changes later when back online!

#5 Github.com rocks

There is no better place to host open source or host your private repositories than Github! Github has a great set of features that are simply amazing. Open source projects are free but to host a private repository will cost a few bucks a month. The prices are cheap and offer so many features that's its a no brainer to use them to host your projects!

Summary

I love SVN but when something better comes along that you can't simply ignore it because your comfortable with something else. I'll still have to use Subversion for some of my older projects, but from now on, all new projects will be using Git and Github.com. Sorry Subversion but it's time we parted our ways! :)