Edexcel International Advanced Level Computer Science, point 6.3.2
Definition
A version control system (VCS) is a tool that records changes to files over time, so that you can recall earlier versions, see who changed what and when, and let several people work on the same project safely. The most widely used is Git (often with a hosting service such as GitHub or GitLab).
Function
- Keeps a history of every saved change to a project.
- Lets you go back to any earlier version if something breaks.
- Lets a team work at the same time without overwriting each other's work.
- Backs up the code (when it is stored on a remote server).
The book names five features: tracking changes (who changed what, and when), version history (compare versions and revert), collaboration, branching and merging, and backup and recovery.
Characteristics and key terms
| Term | Meaning |
|---|---|
| Repository (repo) | The project folder plus its full history |
| Commit | A saved snapshot of the changes, with a message saying what was changed and why, plus the author and time |
| Branch | A separate line of development, so new work (such as a feature or a fix) doesn't disturb the main version |
| Merge | Combining the changes from one branch into another |
| Conflict | When two people change the same lines, so the system can't merge automatically and a person must decide |
| Clone | Copy a repository to your computer |
| Push / pull | Send your commits to a shared (remote) repository / fetch others' changes |
| Revert / checkout | Go back to an earlier version |
Basic workflow (Git)
git clone <address> # get a copy of the project
git checkout -b new-feature # make a branch for your work
... edit files ...
git add . # choose the changes to save
git commit -m "Add login validation"
git push # share the branch
... review, then merge into main ...
git pull # get others' changes
Operation: how branching and merging work
- The team keeps a working, stable
mainversion. - Each person works on their own branch, commits often, then merges back after it's tested and reviewed.
- If the same lines were changed on both, a conflict must be resolved by hand.
Benefits
- Full history: who changed what, when and why (accountability and debugging).
- Easy recovery: undo mistakes and return to a working version.
- Teamwork: parallel development using branches, with merging to combine.
- Experiment safely: try an idea on a branch, then discard it if it fails.
- Backup: a copy on a remote server protects against losing the code.
- Supports code review and releases (tag a version).
- Finds when a bug appeared by checking which commit introduced it.
Drawbacks
- Learning curve: the commands and concepts take time to learn.
- Merge conflicts need careful resolution, and can cause errors.
- Not suited to large binary files (images, video), which don't merge and take a lot of space.
- Large projects with many branches become hard to manage.
- Needs discipline: meaningful messages, regular commits, sensible branches.
- Secrets (passwords, keys) committed by mistake stay in the history.
- Hosting services may involve cost and dependence on a provider.
Worked example
Task: Priya works alone on a quiz app that she commits to a repository regularly. It worked last week, but now it crashes when a quiz ends. Explain how the VCS helps her find and fix the problem.
- History: she looks through the commit log. Each commit has a message, author and time, so she can see what changed since last week.
- Finding the bad commit: she checks out an older commit and tests it. It works, so the bug came later. Checking a commit halfway between the working and broken versions, again and again, narrows it down to the commit "Add high-score table".
- Comparing versions: she compares that commit with the one before it and sees the exact lines that changed, including a new line that divides by the number of scores when there may be none.
- Recovery: she can revert that commit straight away to get a working app back, then fix the line and commit the fix with a clear message.
- Backup: because the repository is also pushed to a remote server, her work is safe even if her laptop fails.
Exam tip: define the key terms (repository, commit, branch, merge) and link benefits to teamwork and recovery. A drawback answer should be specific, such as merge conflicts. If the question asks about a project, say that it keeps the history so you can go back.
Check yourself
What is a commit?
A saved snapshot of changes to the project, with a message describing what was changed and why.
What is a branch used for?
A separate line of development, so new work can be done without affecting the main version.
What is a merge conflict?
When two people change the same lines, so the system can't combine the changes automatically and a person has to resolve it.
How can a VCS help find when a bug first appeared?
By checking out and testing earlier commits (for example halfway between a working and a broken version) to find the first commit where the bug appears, then comparing it with the version before to see exactly what changed.
Give one drawback of using a VCS
Any one of: it takes time to learn; merge conflicts need resolving; it handles large binary files badly; it needs discipline.