Version Control

Dave Braunschweig

Overview

Version control, also known as revision control or source control, is the management of changes to documents, computer programs, large websites, and other collections of information. Each revision is associated with a timestamp and the person making the change. Revisions can be compared, restored, and with some types of files, merged.[1]

Version control systems (VCS) most commonly run as stand-alone applications, but may also be embedded in various types of software, including integrated development environments (IDEs).

Discussion

Version control implements a systematic approach to recording and managing changes in files. At its simplest, version control involves taking ‘snapshots’ of your file at different stages. This snapshot records information about when the snapshot was made, and also about what changes occurred between different snapshots. This allows you to ‘rewind’ your file to an older version. From this basic aim of version control, a range of other possibilities is made available.[2]

Version control allows you to:[3]

  • Track developments and changes in your files
  • Record the changes you made to your file in a way that you will be able to understand later
  • Experiment with different versions of a file while maintaining the original version
  • ‘Merge’ two versions of a file and manage conflicts between versions
  • Revert changes, moving ‘backward’ through your history to previous versions of your file

Version control is particularly useful for facilitating collaboration. One of the original motivations behind version control systems was to allow different people to work on large projects together. Using version control to collaborate allows for a greater deal of flexibility and control than many other solutions. As an example, it would be possible for two people to work on a file at the same time and then merge these together. If there were ‘conflicts’ between the two versions, the version control system would allow you to see these conflicts and make an active decision about how to ‘merge’ these different versions into a new ‘third’ document. With this approach you would also retain a ‘history’ of the previous version should you wish to revert back to one of these later on.[4]

Popular version control systems include:[5]

  • Git
  • Helix VCS
  • Microsoft Team Foundation Server
  • Subversion

The following focuses on using the Git version control system.

Git

Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. Git was created by Linus Torvalds in 2005 for development of the Linux kernel and is free and open source software.[6]

Free public and private git repositories are available from:

Cloning an existing repository requires only a URL to the repository and the following git command:

  • git clone <url>

Once cloned, repositories are synchronized by pushing and pulling changes. If the original source repository has been modified, the following git command is used to pull those changes to the local repository:

  • git pull

Local changes must be added and committed, and then pushed to the remote repository. Note the period (dot) at the end of the first command.

  • git add .
  • git commit -m "reason for commit"
  • git push

If there are conflicts between the local and remote repositories, the changes should be merged and then pushed. If necessary, local changes may be forced upon the remote server using:

  • git push --force

Key Terms

branch
A separate working copy of files under version control which may be developed independently from the origin.
clone
Create a new repository containing the revisions from another repository.
commit
To write or merge the changes made in the working copy back to the repository.
merge
An operation in which two sets of changes are applied to a file or set of files.
push
Copy revisions from the current repository to a remote repository.
pull
Copy revisions from a remote repository to the current repository.
version control
The management of changes to documents, computer programs, large websites, and other collections of information.

References


License

Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Programming Fundamentals Copyright © 2018 by Dave Braunschweig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book