Version Control - SYSC3020-Winter2016/SYSC3020LectureNotes GitHub Wiki

Purpose

Version Control (or Revision Control) tools support collaborative work and provide backups to ensure that work products are not lost.

  • All history is saved
  • Changes can be tracked/visualized (e.g. diff)
  • Concurrent modifications are prevented or at least detected
  • Several versions can be developed and maintained in parallel, developers can easily switch between working on different versions (e.g. the stable branch vs. a development branch where they experiment with new features)
  • VC tools support access control management to enable team collaboration

Repositories and Operations

The main principle of version control is that code (or other work products) is stored in a repository that can be accessed only through specific operations:

  • initialization: create and initialize a new repository
  • commit: store a new version of the code in the repository. The old version is also saved.
  • update: retrieve the latest version from the repository (to update one's local copy)
  • revert: undo the latest commit, go back to previous version
  • branch: branch out from the main sequence of versions, creating a second "current" version associated with a specific name.
  • merge: make a new version from two parallel branches, the new version combining data from the two branches. There is only one branch left after that. Alt

Centralized vs. Decentralized Version Control

In the centralized model, each developer has a workspace ("working copy" of the code), and there is a single master repository that everyone contributes to.

In the decentralized model, each developer has both a local workspace and a complete VC repository locally. The developer commits to his/her local repository, and can also use the other operations defined above. However, new operations must be defined to exchange data between repositories: the main new operations are:

  • clone: create a new repository by making an exact copy of another repository
  • pull: update a local repository by copying over the latest commits from a remote repository.
  • push: update a remote repository by copying over the latest commits from the local repository. This implies that the user has write access to the remote repository: this is typically done to update an online repository (e.g. github).

Example Systems

Example version control protocols: CVS, SVN (centralized), Git, Mercurial (decentralized) Online "forges", e.g. Github, Sourceforge, Gitorious, Google code, host development projects and implement different version control protocols. They are primarily for open-source code, which is typically free to host, but also host private (closed-source) repositories for a fee (this is an example of software as a service, cloud computing). Large software companies typically run their own version control servers.

⚠️ **GitHub.com Fallback** ⚠️