Version Control System (VCS)

Karthikeyan Chinnadurai
6 min readSep 29, 2023

--

A version control system is a software tool that keeps track of changes made to one or multiple files over time. It allows users to recall specific versions of a file and collaborate with others. The version control system is a set of tools that aid a team in managing changes to source code.

The diagram illustrates two files in the local system. The remote repository stores a snapshot of these files as Version 1.

Assume we make some changes in the File 2:

With a Version Control System (VCS), we can easily track the history of a collection of files. File 2 has been updated to version 2.1 and saved in the repository. Each version of the file captures its content at a specific point in time and the VCS allows us to switch between them.

Benefits of VCS

● Software development without using version control is risky.

● Version control provides a backup for uncertainty.

● It offers developers a fast and efficient interface.

● It also enables software teams to maintain their efficiency and agility, even as the team scales up to include more developers.

Git

● Git is a distributed version control system for efficient project management.

● Git is a popular distributed version control system used by developers to manage and track changes to a codebase.

● Git was created by Linus Torvalds in 2005.

Features of Git

History tracking : Git tracks the codebase’s changes, allowing for easy monitoring of its evolution over time.

Staging : Git has a staging area or index where commits can be reviewed before completing the commit

Free and open source : Git is under GPLv2, an open-source license, guaranteeing freedom to share and change free software for all users.

Distributed development : Git is a distributed version control system that allows developers to work independently on a codebase and merge changes later.

Branching and Merging : Git enables parallel development through branch creation and management, with seamless merging tools.

Workflows in Git

Developers must adhere to Git’s specific workflow to ensure proper tracking and merging of changes.

Steps in the Git workflow :

Create a new branch : It is important to create a new branch before making any changes to keep them separate from the main codebase.

Make changes : Revise the code in the branch using appropriate commands to add and commit changes.

Merge changes : Use the appropriate commands to merge the branch back into the main codebase once the changes are ready.

Resolve conflicts : If conflicts arise between the branch and main codebase, resolve them manually.

Push changes : Push the changes to the remote repository to share our work with other developers.

Installing Git

Step 1: https://git-scm.com/downloads

Step 2 : Download for Mac / Windows / Linux

Step 3 : In My case I Choose Windows

Step 4 : Get the .exe file

Git Vs. GitHub

Git

● It is a Software

● Git is an easy-to-use tool that a developer can install on the local system.

● Managed by Linux

● Git is an open-source tool that is freely available for developers.

GitHub

● It is a service

● GitHub is a cloud-based service that allows for remote access.

● Maintained by Microsoft.

● Github is a free online service that provides users with a range of useful features

Git Bash & Git Repository

● Check the version of Git

git --version

● Set up global config variables

git config --global user.name "ckrdp"
git config --global user.email "karthikeyan.rdp@gmail.com"

● Create a “projects” repository in local system

mkdir projects

● Move to the projects repository.

cd projects

● Create a new git instance.

git init

● Create a “index.html” file using touch command

touch index.html

Use vi or nano text editors to edit the file

Give Ctrl+ x, then press ‘y’ for save and hit enter

● Use cat command to view the contents of ‘index.html’

cat index.html

● Check the status of the repository

git status

● Add the file you created to make a commit

git add index.html

● Commit the changes with a short message

git commit -m "First Commit"

● Make some changes to the “index.html” file and save. Use vi or nano command. (this time I use vi command)

vi index.html

Press ‘i’ to insert the contents

Type the contents

Press ‘esc’ key and type ‘wq’. ‘w’ for saving and ‘q’ for quitting. Hit enter

● Now give cat command to view the updated content of ‘index.html’

cat index.html

● We can compare the differences since the last commit using the ‘diff’ command

git diff

● Create a remote repository

● Connect the local repository to your remote repository

git remote add origin https://github.com/ckrdp/sample.git

● Push the file to the remote repository

Refresh your repository page on GitHub

--

--

No responses yet