Branching Out: Understanding the Essentials of Version Control

Version control is like a history book for your project’s code. It keeps track of every change made, so you can always go back to a specific version if needed. It’s like having a shared playground where developers can work together without stepping on each other’s toes. By organising and recording changes, it helps teams collaborate smoothly and avoid confusion. Plus, it offers tools for trying out new ideas without risking the main code. In a nutshell, version control keeps projects organised, teamwork efficient, and code safe.


What do you call a developer who doesn’t use version control?

Types of Version Control Systems (VCS)

Centralised Version Control Systems (VCS)

Centralised VCS work like a central hub where all project files and their versions are stored. Think of it as a library with one big bookshelf for everyone to use. Developers make changes to their own copies of files and then upload them to this central hub. Examples include CVS (Concurrent Versions System) and SVN (Apache Subversion).

Key Points

  • Central Repository: There’s a main storage place (repository) for all files, and everyone works with copies from there.
  • Client-Server Setup: Developers interact with this central hub using special software on their own computers.
  • Version History: The hub keeps track of who changed what and when, creating a history log.


  • CVS: It was one of the first systems of its kind, allowing multiple people to work on the same project.
  • SVN: It’s like an upgraded version of CVS, fixing some of its problems and adding new features.


  • Easy to Manage: It’s simple to set up and manage since everything is in one place.
  • Clear History: You can see a timeline of changes easily, which helps with tracking progress.


  • Dependence on Central Hub: If something goes wrong with the main storage, it affects everyone’s work.
  • Limited Offline Access: You need an internet connection to work with files stored in the central hub.

Centralised VCS systems are good for smaller teams and straightforward projects. They’re easy to understand but can have issues if the central hub isn’t available or if many people are working on files at the same time.

Distributed Version Control Systems (DVCS)

In DVCS, each person working on a project has a complete copy of the project’s history on their computer. This means they can work on the project even without internet access.



  • Developed by Linus Torvalds in 2005.
  • Each user has a full project history on their computer.
  • Supports easy branching and merging for trying out new ideas.
  • Popular platforms like GitHub use Git for hosting projects and collaborating.

Mercurial (Hg):

  • Created by Matt Mackall in 2005.
  • Works similarly to Git, with each user having a complete project history.
  • Easy to use and can be customised with extensions.
  • Integrates well with various development tools and services.


  • Offline Work: Users can make changes and commit them locally, even without an internet connection.
  • Easy Collaboration: Everyone can work independently and share changes later, making teamwork smoother.
  • Flexible Branching: Trying out new features or fixing bugs is straightforward, as developers can create separate branches without affecting the main project.

Distributed Version Control Systems like Git and Mercurial make it easier for teams to work together, even when they’re not online. They offer flexibility, collaboration, and a complete history of the project, empowering developers to work more efficiently.

Key Concepts in Version Control


Repositories are like storage spaces where all project files and their different versions are kept. They’re where developers store their code and its history, allowing them to access old versions and work together.


Commits are snapshots of the project at certain points in time. They show what changes were made and when, helping developers keep track of progress and undo mistakes if needed.


Branches are separate paths of development within a project. They let developers work on new features or fixes without messing up the main project. When ready, changes from a branch can be combined back into the main project.


Merging is the process of putting changes from different branches together. It’s like combining pieces of a puzzle to create one complete picture. It ensures that everyone’s work fits together nicely in the end.


Why did the developer refuse to use any version control system other than Git?
They just couldn’t commit to anything else.

Why Use Version Control?


Version control lets many developers work on a project together without messing up each other’s work. It keeps everyone organised and ensures that changes are merged correctly.

Tracking Changes

It keeps a record of who made what changes to the project and when. This helps teams stay accountable and makes it easier to find and fix mistakes.

Reverting Changes

If something goes wrong, version control lets you go back to an earlier version of the project. This is like having a safety net, so you can experiment and fix mistakes without worrying too much.


What’s the difference between a merge conflict and a bad breakup?
With a merge conflict, you at least have a history of what went wrong.

Best Practices for Version Control

Commit Frequently

  • Make small, frequent updates to track changes effectively.
  • Benefits: Easier debugging, reduced risk of data loss.

Use Descriptive Commit Messages

  • Explain changes clearly in commit messages.
  • Include why the change was made, specifics of what was changed, and use imperative language.

Branch Strategically

  • Use separate branches for different tasks (e.g., features, bug fixes).
  • Regularly merge branches to keep the codebase organised and up-to-date.

Common Commands

git init

Start tracking changes in a folder as a Git repository.

git init

git clone

Copy a repository from the web to your computer.

git clone <repository_url>

git add

Add changes to be saved (commited) later.

git add <file_name>

git commit

Save your changes with a short description.

git commit -m "Commit message"

git status

Check what changes you’ve made.

git status

git push

Upload your saved changes to the web.

git push origin <branch_name>

git pull

Get the latest changes from the web to your computer.

git pull origin <branch_name>

git branch

List: Lists all the branches in the repository.

git branch

Create: Creates a new branch with the specified name.

git branch <branch_name>

Delete: Deletes the specified branch.

git branch -d <branch_name>

git checkout

Switch to a different branch or undo changes in files.

git checkout <branch_name>

git merge

Combine changes from one branch into another.

git merge <branch_name>

git log

See a history of changes.

git log

git remote

Manage connections to other repositories.

git remote add origin <repository_url>

git fetch

Get the latest changes from another repository.

git fetch origin

git revert

Undo a specific set of changes from a previous commit.

git revert <commit_hash>

git reset

Soft Reset: Keep your changes in the working directory and staging area.

git reset --soft <commit_hash>

Mixed Reset: Keep your changes in the working directory but unstage them.

git reset --mixed <commit_hash>

Hard Reset: Discard all changes in the working directory and staging area.

git reset --hard <commit_hash>

Undo Last Commit: Discard the last commit and its changes.

git reset --hard HEAD~1

Move Branch Pointer: Move your branch to a different commit.

git reset --hard origin/master

Unstage Changes: Remove changes from the staging area.

git reset <file_name>

Unstage All Changes: Remove all changes from the staging area.

git reset

These commands cover the basics of working with Git. As you become more comfortable, you’ll likely encounter additional commands and options for more advanced workflows.


Why did the developer always carry a notebook around?
In case they needed to “git stash” some ideas!