Sage-Code Laboratory

Version Control Systems

Source code is difficult to make and subject to change. Sometimes your changes are not good and you have to revert changes and try something else. When you work in a team this becomes a significant problem. To track software changes professional developers are using a special software called "Version Control System" (VCS).

Page bookmarks


Using a version control system adds to complexity of process. What are some of the reason we need such a thing? If is more complicated why will anyone set-up an additional system? Here are some use-cases that explain it:

  1. Team collaboration
  2. Improved on-boarding
  3. Test automation
  4. Release automation
  5. Root cause analysis

Popular version VCS

In the past there ware many attempts to make better version control systems. The most desired features are: network efficiency, compression capability, storage efficiency and decentralization. Some are more potent than others:

Basic Concepts

A version control system has several concepts to learn before you can use them.

Cloud based SCM

Normally a repository is local to a company and is stored on a server. Large teams and open source software can use cloud based repository. Lately there are several most popular organizations that enable creation of public and private repositories:

These organizations have also provided tools to maintain project source code and work items. Now any developer can start a project very fast and can invite other developers to join and work together on open source projects.

One of the most important aspect of software engineering is the ability to work in a team of developers. For this you need several skills that can be learn by practice.

What is Git?

Git is a distributed version control system that is used for software development and other version control tasks. A version control software can store source code or text in a repository and track modifications in a multi user environment.

Git was created by Linus Torvalds in 2005 for development of the Linux kernel.

Why Git is so popular?

Several features makes Git popular:

To develop a database you can work in a large team. For this you have to understand some terms and tools before you can collaborate with your team. Most of the companies are using GIT to control versions of software.

Main Terms

First, we need to introduce some Git-specific terms which may have different meanings in other version control systems such as Subversion or Mercurial.

Git is a distributed version control system. It is used to store source code that is based on text files organized in folders and sub-folders. This structure is named Git’s working tree. It is the directory where you can edit files and it is always part of a repository.

Git can have local repositories that have a working tree and so-called bare repositories, used on servers as central repositories that don’t have a working tree.

Git Architecture

Git is a distributed version control system that allows different developers to work on the same codebase collaboratively. Git's architecture can be broadly categorized into three major components: the repository, the working directory, and the staging area also referred to as the index.


The repository is the central part of Git's architecture. It is where all the changes made to the codebase are stored. Each change is stored in a commit, which contains a snapshot of the entire codebase at that point in time. The repository also contains information about the different branches, tags, and remotes.

Working Directory

The working directory is where you have a copy of the repository. When you make changes to the codebase in the working directory, Git tracks these changes and allows you to commit them to the repository when you are ready.

Staging Area/Index

The staging area, also known as the index or cache, is an intermediate stage between the working directory and the repository. The staging area is where you can selectively add changes from the working directory before making a commit. This allows you to commit only the changes that you want and keep the rest of the changes for a later commit.

Communication Protocols

Git supports multiple protocols for communicating with remote repositories. The most common protocols that Git uses are HTTP, HTTPS, SSH, and Git. Git's protocols are designed to be lightweight and efficient, allowing for fast communication between the client and the server.

In conclusion, Git's architecture consists of three main components: the repository, working directory, and the staging area. It provides the flexibility of using different protocols to interact with remote repositories depending on the authentication and speed requirements of the project.

Git Commands

Here is a table with the most frequent git commands. Any developer should know these commands otherwise you will not be able to maintain a repository for your project.

Command Description
git init Initializes a new Git repository in the current directory.
git clone Makes a copy of a Git repository and stores it on your local machine.
git add Adds changes in the working directory to the staging area.
git commit Records changes to the local repository along with a message describing the changes.
git push Pushes the local commits to a remote repository.
git pull Fetches changes from a remote repository and merges them into the local branch.
git branch Lists all local branches in the current repository.
git checkout Switches to a specific branch or commit.
git merge Merges changes from one branch into another.
git status Displays the current state of the working directory and staged changes.

Git Branching Strategy

A Git branch is a line of development in a Git repository. It is a lightweight way to create isolated line of development that you can experiment with without affecting the main code.

A Git branching strategy is a set of guidelines for how developers should use branches in a Git repository. It helps to ensure that code is organized and easy to work with, and that changes are made in a way that minimizes the risk of conflicts.

There are many different branching strategies that can be used, and the best one for a particular project will depend on the size and complexity of the project, the number of developers working on it, and the release cycle.

Feature branking

One common branching strategy is to use a feature branch for each new feature that is being developed. This allows developers to work on features in isolation, and to merge changes back into the main branch when the feature is complete. This can help to prevent conflicts, and it makes it easier to track changes and identify the source of bugs.

Release branches

Another common branching strategy is to use a release branch for each new release of the software. This allows developers to work on bug fixes and other changes that need to be made for the release in isolation, and to merge changes back into the main branch when the release is ready. This can help to ensure that the release is stable, and it makes it easier to roll back changes if necessary.

The best way to choose a branching strategy is to experiment with different approaches and see what works best for your team and your project. There is no one-size-fits-all solution, and the best strategy will vary depending on the specific circumstances.


Here are some of the benefits of using a Git branching strategy:


Here are some of the challenges of using a Git branching strategy:

Overall, a Git branching strategy can be a valuable tool for managing software development projects. However, it is important to choose the right strategy for your project and to be aware of the challenges involved.

Git Forking

Git forking is the process of copying an existing Git repository to your own account. This allows you to work on changes to the code without affecting the original repository.

A pull request (PR) is a request to merge changes from your forked repository into the original repository. Once a PR is merged, your changes will become part of the original code.

A development branch is a branch that is used to develop new features or fix bugs. It is typically created from the master branch and then merged back into the master branch when the feature or bug fix is complete.


Here are some of the benefits of using Git forking and PR's:


Here are some of the challenges of using Git forking and PR's:

Overall, Git forking and PR's are a valuable tool for collaboration and code development. However, it is important to be aware of the challenges involved.

Git Software

To use Git you have to install Git software on your computer. This consist of Git client for your operating system and user interface tools to aid you visualizing the code.

You can download Git for Mac, Windows, Linux or Solaris:

Once you download the software read documentation:


Git commands are complex and difficult to master. For improving productivity you can use a graphical user interface (GUI). This is a program that may aid in your quest:

I have installed on my PC these two:

More tools:


On server you can have 2 options. One is to host on the cloud and second is to host on your own server. Git repository can be installed on Linux or Windows servers. When you install Git it has only basic capabilities. Most popular cloud services include a web user interface:

GitHub and BitBucket are SAS (Software as Service). Basic services are free, for open source projects. Private projects support limited number of users and you have to pay for more users. Some important features are not available for free.

You can install only GitLab on your own server. This will allow creation of very large, distributed projects. It can support unlimited number of users in a private environment behind a firewall.

Read next: Open Source Projects