Version Control, also referred to as Source Control Management (SCM), Software Version Management, or a variety of other acronyms, is a crucial part of modern game development.
What Is Version Control?
We'll start with a scenario at the most basic level.
A programmer is creating a new application, and it contains many lines of code and files. Periodically, during the course of development, he reaches a point where the code is functioning properly, so he checks in the files to the version control repository. Imagine this as making a photocopy of a page of text, and storing it in a file cabinet with older copies of the same page.
He continues to develop the application, when a week later, he realizes that he has made a critical logic error and needs to step back to a previous version of one or more files. Version control allows this. By checking in the files routinely, he has snapshots that have timestamp info, as well as revision history. It is a trivial matter to run a comparison between two versions of the same file to determine what has changed.
Why Is Version Control So Important For Game Development?
When it comes down to it, game development is just like any other complicated software development project. You have a group of developers all working with the same set of files to complete the project.
What version control allows you to do is check out files to your account, and either lock them to that account, so that they are read-only to others, or so that they can be checked out for editing by multiple people simultaneously.
Locked Versus Shared Editing
Locking files makes sense at a basic level. Preventing other users from changing a file while you have it open avoids conflicting changes. This is critical with binary files (images, game levels, audio, etc.).
Why allow multiple developers to edit the same file simultaneously?
Having only one person work on a file at the same time is truly the ideal scenario; however, there are times when it is just not practical. In complex development projects, it is sometimes necessary to have certain files be writable by multiple devs.
How is this achieved? There is a concept in programming called merging. There are a number of excellent tools available that allow the text-only files of the application's source code to be compared, and the changes are highlighted. An experienced developer is able to see if there are going to be conflicting changes, and adjust his own code accordingly.
How is a merge done? At a high level, we'll use the following example:
- Programmer A changes a file that Programmer B is dependent on.
- Programmer A checks the updated file into version control
- Programmer B completes his own changes to the application, and updates his local copy of the application code with what is on the server. The files that he has locally modified are not pulled down, and he is notified if any files he has modified have been changed on the server.
- Programmer B performs a merge, integrating the changes made on the server with those he has made locally.
- Once Programmer B confirms that the program still functions properly after combining the changes, he checks in the modified version of the conflicting files, resulting in both Programmer A and B's changes being available to the rest of the team.
Where Does Merging Fail?
Like most tools, it is only as good as its user. If a programmer fails to merge code properly, or checks in his own code, without confirming that it works properly with what is in the version control repository, he can break the application for everyone else until the code is fixed. In a small team, this is an annoyance. In a large studio, it can cost thousands of dollars (or more) in wages as teams lose productivity.
How Does Version Control Benefit Non-Programmers?
There are a variety of ways that a version control system can enhance the production pipeline.
- Backups: A version control repository means that everyone can have a backup copy of the entire game's code and assets on their machine. In the event of a catastrophic disaster, the chances of being able to recover the entire project are very high. The failure of a key programmer or artist's desktop does not mean the loss of all the assets they were working on.
- Build distribution: You have a comprehensive way of ensuring all developers have a current version of the game to test.
- Testing: Completed builds can be stored for regression testing
- Artist: Able to keep multiple versions of an asset in the event that changes need to be rolled back or referred to.
- Security and version control of design documents.
Version Control Software Systems
There are a number of options available. The most commonly-used packages are:
- git: An open source distributed-model version control system, git features several different workflows to ensure smooth development from a variety of developers.
- Subversion™: An open source version control system, Subversion is widely used both for open source development, and general software development projects.
- Perforce: A professional-level, closed-source version control server, with client support for the three major platforms, plus a Web UI, Perforce is favored by many game development studios. With the recent addition of a 20-user free license, Perforce is making moves to take over small-team development version control.
Interested in setting up a version management server of your own? Here are step-by-step instructions on how to set up Perforce.