Git is our tool of choice for version control.

"Git along little doggie!"

Version control, Git, and Subversion are terms you've probably heard mentioned by a developer or project manager at some point. What do they mean, however, and what do they matter to a project? At CommonPlaces, we use version control on all of our clients' projects, and Git is our tool of choice, as well as the one preferred these days by many developers in the industry.

In the software world, version control refers to using a system to track every change ever made to the files that make up your application. This is commonly called a VCS, or version control system. Tools like Git, or Subversion, which is also popular, work by storing the changes to all files under version control in a database, or repository. Each change, or set of changes, has a revision number or ID that can be used to see exactly what changed at any particular point in the project 's development.

Typically, a developer will do some work locally, making changes and testing, until reaching a point when deciding to commit the changes. One simple command is all that is required to tell the VCS that it's time to update its database with the record of what changed in that file or group of files. You can commit whenever you like, although the mantra "commit early, commit often" certainly is one to live by.

Let's say you did some work, maybe a whole LOT of work, and then realized you 'd pursued the wrong path. You need to go back to the way things were before you started. With version control, it's simple. With one command, you can get right back to the state of your code before you started. In fact, as long as you've been continually committing your work, you can retrace your steps anywhere along the way.

Suppose a file is accidentally deleted; or worse, something catastrophic happens and multiple files have been lost, possibly even the entire copy of the code. If you've been committing and pushing your changes up to the main repository, you can rest assured that it isn't gone for good. One command will bring it all back.

Version control is particularly helpful when you have more than one person working on a project, which is often the case at CommonPlaces. Each developer can be working in a separate sandbox, but sharing access to the same repository. Then, when a developer commits the work and pushes it up to the main repository, everyone else can pull down a copy of it and update their individual sandbox with the latest code.

It's also not unusual for the same section, or line, of code to be changed by two people. With version control and other tools which allow you to compare files, it's easy to see who changed what and resolve any conflicts that may have occurred. Even if just one person is working on the project, version control makes it possible to go back and look at any change along the way, solving problems like what recent change broke something that used to work.

Sometimes a site adds new features, while simultaneously some rudimentary tweaks or improvements are also being made. The half-finished new feature isn't ready for prime time yet, but those tweaks need to be released as soon as possible. How do those changes that are ready get pushed to the live site?

By using version control this becomes effortless, and is called parallel lines of development. New feature work can be done in a branch, which is created by taking a snapshot or copy of the code, then doing the new work in that copy without affecting the main line of development. When the new work has been completed and tested, the branch is merged back into the main line. This automatically combines all the code changes for the new feature with any modifications that may have happened in the meantime, like those tweaks or quick minor improvements previously mentioned.

Version control benefits every project's stakeholders by improving efficiency, communication, and source code management. Tools like Git and Subversion are integral parts of the development process. I've been using different VCS methods myself for over 20 years now, and I can't imagine doing it any other way.

What methods work for you?

Leave Your Comment