What is Version Control?
A: “Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.” (Source: git-scm)
To sum up: It’s possible to view (and recover) the changes of a file throughout its development. Each commit¹ stores the changes made to the file and has an associated version with it. The commit saves the current state of the file in this version.
Among the benefits of using a version control system, we have:
- ability to restore previous versions of the system
- code comparison
- management of changes
- code integration
How it works:
- There’s a central server (called Repository) that is responsible for versioning system
- This central repository enables multiple clients can access, view, edit and send new codes if needed.
An example of a simple flow with two persons:
- One Person creates a file with content My Program
- One Person commits to Central Repository
- Other Person downloads the files that are in Central Repository
- My Program was on Central Repository
- On this moment, both One Person and Other Person have the file with content My Program locally, and the file also exists on Central Repository
- Other Person changed the contents of My Program to My Edited Program
- Other Person commits to Central Repository
- On this moment, the current and latest version of the file is the one with content My Edited Program
- One Person changed the version that he had (My Program) to My Program With My Edits
- One Person tries to commit
- The version control system warns that the version that One Person has isn’t the latest, so he cannot commit
- One Person needs to download the latest version of the file
- There are differences between the latest version of the file and the version that One Person wants to commit
- These differences can be handled automatically by the version control system, or if not possible, manually
- Once downloaded the latest version and resolved the differences, One Person can commit normally
Among some of the tools for centralized version control we have: CVS, Subversion (SVN), Git, among others. No, Dropbox is not a version control system. Currently, SVN and Git seems to be the most commonly used tools.
¹ Commit: Permanently save all changes to the desired file
References: Integração contínua: uma introdução ao assunto (pt-br)