DEV Community

Immaculate Njoroge
Immaculate Njoroge

Posted on

Introduction to Version Control Systems

A Version Control software provides a mechanism to track changes in files over a period of time ensuring that one recalls specific versions later.

It helps developers in teams as one developer may be working on a new feature while another developer fixes an unrelated bug by changing code ensuring each developer may make their changes in several parts of the file tree. The source code for a project, app or software component is typically organized in a folder structure or "file tree".

Primary benefits from version control are as follows:

  1. Long term change or history: Having the complete history enables going back to previous versions to help in root cause analysis for errors. Also important when fixing problems in older versions of software.

  2. Branching and merging. Creating a "branch" in VCS tools keeps multiple streams of work independent from each other while also providing the facility to merge that work back together, enabling developers to verify that the changes on each branch do not conflict.

  3. Traceability. This is done through Issues and Pull Requests.
    Each work item can be planned as an Issue, with tags. When you commit code relevant to that Issue, referencing it in the commit message by the Issue number (eg #123) will link that commit on the Issue page.
    It helps one in not referencing the Issue in every commit and one can create a Pull Request for a long-running branch. The Pull Request stays up to date as you push changes to the branch, and you can reference the Issue from the Pull Request description in the same way (#123) to tie the two together. Pull Requests are GitHub's solution to code reviews,

In this article I am focusing on Git as a Version Control System.

It was created in 2005 by Linus Torvalds. In addition, is a free open source software with a distributed architecture. Distributed Architecture means that each person contributing to the repository has a copy of the repository on his own machine. This makes the operations really fast.

One can download Git here:(https://git-scm.com/downloads)

Basic Git Commands and Functions:
Once you have installed Git, the very first task can be to create a new repository so that Git can start tracking your files. To start this, you need to provide basic configuration information to GIT like who you are. This can be achieved in Git as below:

Image description
Configuring commands
git config --global user.email "jane_imma@gmail.com"

The “— global" command is user-specific, meaning it is applied to an operating system user. Global configuration values are stored in a file that is located in a user's home directory.

The "--system" command is a system-level configuration is applied across an entire machine. This covers all users on an operating system and all repos

Creating a new repository
A repository is the place where we will keep all the files that we want Git to track.

We use the “git init” command.

Image description

The folder first_repo is where we have created a new repository. Remember that the repository is the place where we will keep all the files that we want GIT to track.
The init command creates an empty git repository under the folder “first_repo”. If we check the contents of the first_repo folder, we will see a directory “.git

Cloning to a specific folder
git clone <repo> <directory>

Clone the repository located at <repo> into the folder called ~<directory>! on the local machine.

Cloning a specific tag
git clone --branch <tag> <repo>
Clone the repository located at <repo> and only clone the ref for <tag>.

These are some of the commands which I have learnt and will keep updating as I progress.

Top comments (0)