Created
Jan 30, 2026
Last Modified
3 days ago

#Git for Begineers

Git for Beginners: Basics and Essential Commands

Now, let’s understand Git and VCS.

When I started learning web development, managing my code felt chaotic.
Files like project file1, project file2 and project file last were everywhere
I often broke things and had no easy way to go back.

That’s when I realized why Git exists.

This blog explains Git from scratch, in simple and beginner-friendly language.

Introduction to VCS and Git:

Question: How will you maintain different versions of a file?

Answer: Create a copy of the file and make changes to the new file.

Create copies of the file for each version.

Issues with manual version control:

• Difficult to identify the changes between two files

• Not efficient with projects having thousands of files

• Difficult to collaborate with the team and other programmers

• Difficult to store metadata such as who made what changes, date and reason. It is quite difficult to maintain file versions manually. This is where the Version Control System helps you. The basic Version Control System is available on Google Drive also (if any of you have used it).


Introduction to VCS:

What is VCS:

The Version Control System (VCS) helps you manage the changes made to a specific directory or a project over the course of time.


Why Use VCS?

• It helps you keep track of all the modifications that are made to the code.

• It helps you collaborate with other programmers efficiently.


Advantages of VCS:

The following are the advantages of VCS over manually controlled versions:

• Makes it easy to find out the changes between different versions of a file.

• Highly efficient for large projects with thousands of files.

• Makes it easy to collaborate with other programmers.

• Makes it easy to store metadata.

• Makes it easy to create backups and revert changes.

• Makes it easy to share code on multiple systems/users.


How does the VCS Work:

Collaboration:

  1. You can upload your local Git repository to a server, which includes all the versions of code. Such a repository is called a remote Git repository, which is also known as a central repository.

  2. Collaborators can download this remote Git repository as their local Git repo.

3. They can make changes to their local Git repo and add new versions.

  1. They can also update the remote Git repo by pushing these newly added versions to remote Git repo.

  2. Other collaborators can download and update their local copies with the new changes.


How does the VCS works.

Some keywords used while discussing VCS:

• Remote/Central/Master Repository - A repository hosted on server/cloud service like GitHub, Bitbucket, etc., where we can store the main codebase.

• Local Git Repository - A local repository where we store all the changes before pushing to the remote repository

• Pushing - Pushing the changes made locally to the remote repo.

• Pulling - Pulling the current state of a project, including all the updates/changes from a remote repository • Master - Main branch in which all the deployable changes are stored.

• Head - Pointer to the current branch/state of the code.


Now, let’s understand Git:

Git is a distributed version control system that helps developers track the history of their code, manage files over time, and clearly understand who changed the code, what was changed, and when it was changed.


Benefits of Git:

1. Faster as most of the operations are performed locally.

2. Enables flexible version control.

3. Easy to revert changes and move to the previous state.

4. Useful for distributed teams.

5. Maintains integrity while using hash values.


Why is Git used (Explain example based ):

Let’s suppose I have a project, and three people (including me) are working on the same project.

I am working on the homepage,
one person is working on the login feature,
and another person is working on the dashboard.

Now imagine we are not using Git.

Everyone starts changing files and sending code through WhatsApp, email, or pen drive
Very soon, problems start:

  • Someone’s code overwrites another person’s work

  • We don’t know who changed what

  • If the project breaks, there is no easy way to fix it

  • We waste time resolving confusion instead of coding

This is exactly why Git is used.

With Git, each of us can work independently on the same project.
Every person saves their changes as commits, and Git keeps a clear record of:

  • Who made the change

  • What was changed

  • When it was changed

If something goes wrong, we can go back to a previous working version without losing all progress.

Git also allows us to work using branches, so one person’s changes do not affect others until they are ready.
This keeps the main project safe and stable.

In simple words, Git is used to avoid confusion, prevent code loss, and allow smooth teamwork.
It makes teamwork organized, safe, and professional.


Some keywords/Terminologies used while discussing Git:

Before using Git commands, I first needed to understand some basic terms.

  1. Repository (Repo):

    A repository is a folder where Git tracks my project.
    It contains my code and the complete history of changes.

    Once I run git init inside a folder, it becomes a Git repository.

  2. Working Directory:

    The working directory is where I write and edit my code.
    Any change I make to files first happens here.

    Git does not automatically save these changes — I have to tell Git what to track.

  3. Staging Area:

    The staging area is a temporary place where I prepare my changes before saving them permanently.

    When I use git add<file Name>, I move my changes from the working directory to the staging area.

    It helps me decide which changes are ready to be committed.

  4. Commit:

    A commit is a snapshot of my code at a specific point in time.

    When I commit, I am telling Git:

    Each commit has a unique ID and a message that explains what was changed.

  5. Branch:

    A branch allows me to work on new features or experiments without affecting the main code.

    The default branch is usually called main.

    Branches make it safe to try new ideas and fix bugs.

  6. HEAD:

    HEAD shows where I am in the project history.

  7. Remote Repository:

    A remote repository is a version of my project stored online (for example, on GitHub).

    It allows me to:

    • Backup my code

    • Share my work

    • Collaborate with others


Here, Basics Git Commands:

When I started using Git, I realized that I don’t need to learn too many commands at once.
A few basic commands are enough to manage a project confidently.


Below are the most important Git commands for beginners.

  1. git init

    When I run this command, Git starts tracking my project by creating a hidden .git folder.
    Now my project becomes a Git repository.

    bash
    git init
  2. git status

    This command shows the current state of my project.

    • Which files are changed

    • Which files are staged

    • Which files are not tracked yet

    bash
    git status
  3. git add <file name>

    This command moves my changes to the staging area.

    bash
    git add <file name>
    git add.
  4. git commit -m “ “

    A commit is like taking a snapshot of my project at that moment.
    The message helps me remember what I changed and why.

    bash
    git commit -m "Initial project setup"
  5. git log

    This command shows the history of commits.

    • All previous commits

    • Commit messages

    • Dates and authors

    bash
    git log
  6. git diff

    This command shows the difference between changes.

    bash
    git diff
  7. git revert

    git revert is used when I want to undo a change safely, especially in a shared project.

    bash
    git revert <commit-id>
  8. git reset --hard

    bash
    git reset --hard <commit-id>

Basic Git Command Workflow

Basic Git command workflow