1. What is a Version Control System (VCS)?
Version control, also known as source control, is a system that helps track and manage changes made to software code over time.
Why is it required?
As a project grows, code is continuously updated—new features are added, bugs are fixed, and existing logic is modified. In such cases, it becomes difficult to answer questions like:
- Who made a specific change?
- When was the change made?
- Why was the change introduced?
- How can we revert to an older stable version?
A Version Control System solves this by maintaining a complete timeline (history) of code changes, making collaboration, tracking, and rollback easy and reliable.
Famous VCS Tools
- Git (Most popular)
- Apache Subversion (SVN)
- Piper (Used internally by Google)
2. Introduction to Git VCS
Download Git from the official website:
https://git-scm.com/install/
Verify Installation
git
git -v
If Git is installed correctly, it will display the installed version.
What is Git?
Git is a distributed version control system that allows multiple developers to work on the same project simultaneously while keeping track of all changes.
Why Git Configuration is Required?
In an organization, multiple developers work on the same codebase. Git uses global configuration (username and email) to identify who made which changes in the commit history.
Setting Up Git Global Configuration
First let's create a folder where we keep our source code and config the user name and email to it.
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
3. Version Controlling with Git
Initializing a Git Project
By default, a folder is not Git-enabled, and Git does not track it.
To enable Git tracking:
git init
This initializes a Git repository in the folder.
Tracking Files
- After initialization, files are still untracked
- You must explicitly add files to Git
git add index.js
git add <File Path Name>
Once added, Git starts tracking changes to the file.
Viewing Changes
git diff
Shows differences between the working directory and the staging area.
Add Multiple Files
git add .
Adds all modified and untracked files at once.
By default, Git does not track any folder or file on your local machine unless you initialize it and add files manually.
Removing Files from VCS
git rm <FILE_PATH>
Introduction to Commits
What is a Commit?
A commit is a snapshot of the staged changes at a specific point in time.
Committing Files
git commit -m "commit message"
Staging Area
The staging area is an intermediate step where files are prepared before committing.
Viewing Commit History
git log
git log --oneline
git diff <to see the changes in code file>
git show <commit id> to see the changes made in particular commit
git blame <File Name> to see the changes made in particular file by whom
Reverting Back
git reset --hard <commit id>
here we are moving our head so we will loose the below commits
whenever we are saying VCS we should have something when we do any thing wrong we can revert back.....so Git allows reverting commits to return to a previous stable state when required.
In this feature we use the concept of Linked List head points to the latest commit.....so we just point our head where we want to revert.
git revert <commit id>
✍️ Author: Omkar Sharma
📬 Feel free to connect on LinkedIn or explore more on GitHub






















Top comments (0)