29.1 Version Control

A version control system is a program that can record multiple versions of a source file, storing information such as the creation time of each version, who made it, and a description of what was changed.

The Emacs version control interface is called VC. VC commands work with several different version control systems; currently, it supports Bazaar, CVS, Git, Mercurial, Monotone, RCS, SRC, SCCS/CSSC, and Subversion. Of these, the GNU project distributes CVS, RCS, and Bazaar.

VC is enabled automatically whenever you visit a file governed by a version control system. To disable VC entirely, set the customizable variable vc-handled-backends to nil (see Customizing VC).

To update the VC state information for the file visited in the current buffer, use the command vc-refresh-state. This command is useful when you perform version control commands outside Emacs (e.g., from the shell prompt), or if you put the buffer’s file under a different version control system, or remove it from version control entirely.

VC is also enabled automatically in Dired buffers (see Dired, the Directory Editor) showing directories whose files are controlled by a VCS. All VC commands described in this section can be invoked from any Dired buffer showing a directory with VC-controlled files; any files that are marked in a Dired buffer (see Dired Marks vs. Flags) are considered to belong to the current fileset, and VC commands operate on the files in this fileset. This allows you to construct VC filesets including any files you want, regardless of their VC state. (If no files are marked when a VC command is invoked from a Dired buffer, the file shown on the current line in the buffer is considered the only file in the fileset.)