web development

The Transition to GIT

Posted by Lyemium Editorial on Jun 05, 2010

If you haven't heard by now Drupal.org is making the transition to GIT for its VCS (Version control system). For developers; now is a good time to get into the habit of practicing the new format.

Most developers are familiar with using Subversion for most of their projects this article is to provide ways in making the transition as smooth as possible.

What is Version Control?

Version control, alternately known as revision control or source code management, is a system that maintains versions of files at progressive stages of development. The version control system is similar in theory to backing up files, but performed in a smarter way. Every file in the system has a full history of changes, and can easily be restored to any version in its history.

The basic concept you must understand is the difference between Subversion and Git, is that a Subversion repository is hosted remotely and requiring the user to checkout the files that are in that repository onto a local machine. With Git however, you actually get the whole repository locally where you then also checkout the files that are in that local repository.

Version control, also known as source control or revision control is an integral part of any development workflow. A way to understand version control is that it is essentially a communication tool, just like email or IM, but it works with code rather than human conversation.

Version control has it's advantages such as it:

  • allows programmers to easily communicate their work to other programmers
  •  
  • allows a team to share code
  •  
  • maintains separate “production” versions of code which can be deployable
  •  
  • keeps track of all old versions of files
  •  
  • prevents work from being overwritten

As with many things in life, Git began with a bit of creative destruction and controversy. The Linux kernel, an open source software project of fairly large scope, for most of the lifetime of the Linux kernel maintenance (1991–2002), had changes to the software that were passed around as patches and archived files. In 2002, the Linux kernel project began using a proprietary DVCS system called BitKeeper.

By 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool’s free-of-charge status was revoked. This prompted the Linux development community to develop their own tool based on some of the lessons they learned while using BitKeeper. Some of the goals of the new system were as follows:

  • Speed
  •  
  • Simple design
  •  
  • Fully distributed
  •  
  • Able to handle large projects such as the Linux kernel efficiently

This then gave birth to GIT. Git has evolved and matured to be easy to use and yet retain these initial qualities. It’s incredibly fast, it’s very efficient with large projects, and it has an incredible branching system for non-linear development.
 

Git & SVN

Most development servers and developers use Subversion for their VCS needs. The transition to Git will be slower than usual, especially if you are collaborating with other people who do not know Git and are unwilling to learn Git. So if all of your repos belong to SVN, how can you get into the practice of using Git in your daily work life? In steps git-svn is a great tool that allows you to work with a remote Subversion repository while using Git on your local machine. You can run all of your normal Git commands locally, merging, branching and merging Subversion branches all without using Subversion commands while keeping your remote Subversion repository intact. The advantages of this is that other developers can still use it exactly how they are accustomed to and run Subversion commands whenever they want.
 

Pull often

A mentionable best practice would be to pull often. Pulling often keeps your code up to date and cuts down on any duplicated work. It is quite common and often frustrating when you spend hours working on a feature only to find out that someone else has already implemented it and pushed it to the repository. By pulling often means you get the most recent and up-to-date code possible not only that but it keeps developers working on a project in the loop for any changes or bugs that may develop in the process.

Conclusion

With Git coming to Drupal, you can finally have everything in one VCS. It's time for developers especially those using drupal to embrace the new techonology as CVS will soon be a thing of the past. To get a better idea about using git visit: http://progit.org/book/