Overview of Version Control

Version control (also known as Source Control Management or SCM) is a set of tools and procedures to safeguard and manage files and changes made to them over time. A version control system frees you from having to manually manage access to the files that comprise a software project and track changes. Version control systems take care of these details, allowing you to concentrate on writing and testing code.

You should read this chapter if you’re new to version control and are interested in adopting version control practices in your projects. After reading this overview, you’ll understand how version control provides an infrastructure that improves the development experience for single developers and multiple developers working in the same project.

This chapter describes the essential aspects of version control systems. If you’re familiar with version control, you can skip this chapter.

Have you ever wondered which files you modified to correct a problem in one of your projects? Or, how about undoing changes you made the previous day because you came up with a better solution to the problem? A version control system can give you answer to the first question quickly; you don’t need to check modification dates or comments inside source files. It would also let you discard multifile changes so you can reimplement the solution to a problem without manually identifying and removing each change in every file you touched.

A version control system has three major parts: a repository, a client, and a server. The repository is a directory tree or database that contains the files managed by a version control system. The files stored in the repository are called managed files. Repositories can reside anywhere but are usually placed in a computer managed by a system administrator who sets access to the repository and ensures the persistence of its contents through regular backups.

The client is the program developers use to interact with a repository. The server is the process that actually modifies the repository. When a developer issues a command to the client, the client talks to the server process to carry it out.

Every developer authorized to access the repository can copy files from the repository into a local directory, also known as a working copy. This is where developers make changes to the project; they never work with the files in the repository. Developers normally don’t have access to each other’s working copies. This feature provides privacy and security because developers are unaware of what their peers are doing until they publish or submit their changes to the repository.

When a developer submits changes to a file in the repository, its version number (also known as the revision number) is incremented. The history of each file is recorded as a set of revisions, which you can retrieve and compare individually.

Version control provides several benefits, including:

Consider using version control when several developers work on one project at the same time. Single developers can also benefit from the structure that version control adds to the development process, such as revisions and change management.

Xcode provides a common interface to various version control systems, which include the open-source CVS (Concurrent Versions System) and Subversion, and Perforce. Xcode makes it easy to perform most version control tasks as you develop. It also tells you whether you’ve modified managed files in your local copy of the project. Managing Projects and Managing Files describe Xcode’s version control interface in detail.