Git for Beginners: Basics and Essential Commands
MCA graduate | Software developer documenting my learning journey and sharing beginner-friendly tech concepts.
Introduction
When multiple people work on the same project, managing the changes becomes a challenge. Files get overwritten, updates are missed, and no one is sure which version is correct. To address this issue during the software development process, tools known as version control systems (VCS) were developed.
Git is one such system, and today, it plays a crucial role and is the most widely used version control tool in the world.

What exactly is Git?
Git is the version control system that helps developers track changes in their code over time while developing software.
in simple words
Git keeps a history of your project that tracks the changes made, when they were made, and by whom they were made.
Git is not a programming language.
Git is not a code editor.
Git is not only for big companies.

Why was Git Created?
Before Git, developers used manual methods, such as pen drives, email, or shared folders, to manage code. These methods caused:
Overwritten file
Lost Changes
No history of work
Difficult collaboration
Git was created to solve these problems by providing a structured and reliable way to manage code changes.
Git as a Distributed Version Control System
Git is called a Distributed Version Control System (DVCS).
Let’s understand what Distributed Version Control or “Distributed” means.
Distributed Version Control is a system where every developer has a complete local copy of the entire project, including its history, and they can work offline. Changes can be made locally, and later synchronised with other developers.
Git Basics and Core Terminologies
Let’s understand the basic and core terminology of Git. The four terminologies are: Repository, Commit, Branch and HEAD. These terminologies form the basic foundation of how Git works.
Repository
A repository, or repo, is centralised digital storage that developers use to make and manage changes to an application’s source code.
In simple words, think Repository as a:
A project file + Time machine of all versions inside it.
It contains:
Your project file.
The history of every change
All commits, branches, and configurations
Repositories are of two types:
Local Repository: On Your Computer.
Remote Repository: On platforms like GitHub, GitLab, or Bitbucket.
Commit
Commit is a feature that lets developers save all changes they’ve made to the code files in the branch. When the Developer describes changes, it allows team members to be aware of the changes and the reason they were made.
In simple terms, a commit can be described as
A commit is like a snapshot of your project at a specific moment.
Each Commit records:
What changed
who made the changes
when the changes were made
A message explaining the change
Example: git commit -m “ added homepage layout”
git commit -m "Added homepage layout"
Branch
A branch can be described as a Separate Workspace where you can work on new changes without disturbing the main project. A branch is a separate line of development inside your repo.
Branches make it easy to:
Manages different tasks or features independently.
Test changes without affecting live code.
Collaborate with others efficiently.
By default, Git gives you a main branch (often called master/ main). From this line, u can create your own branch to add a new feature without affecting the main project.
git branch feature-login
git checkout feature-login
HEAD
HEAD is a pointer that identifies the current active branch and the latest commit within it. In other words, HEAD is a pointer that tells Git where you currently are in your project’s history.
More specifically:
HEAD points to the current branch.
And within that branch, it opens to the latest commit.
Example:
If you are on
main, HEAD points to the latest commit of main.If you switch to
feature-login, HEAD moves to that branch’s latest commit.
git checkout main
This moves HEAD to the main branch.
Essential Git Commands You Must Know
The following Git commands form the foundation of the entire Git Workflow.
git initUse it when you want to use git in your folder.
git init
This command:
i) creates a hidden .git folder.
ii) Converts your normal folder into a Git repo.
iii) Allows git to start tracking the changes.
git statusThis command is used to display the state of the working directory and the staging Area. It shows which changes have been staged, which have not, and which files are not being tracked by Git.
git statusgit addAdd your file changes to Git’s stagging area (temporary place before committing. Basically stagging area allows you to choose which changes you want to in your next commit.
Example:
git add . # to add the whole file. git add file1.txt file2.txt # to add the 2 files.git commitThis command simply takes the files from the stagging area and saves them in the repository with a message.
Messages here basically explain what and why the code is changed / update.
git commit -m "Added HomePage URL"git log
git log basically shows all previous commits in your repository.
Use to see:
i) commit ID (SHA hash)
ii) Author
iii) Date
iv) Commit Message
Example:
git log
Compact view:
git log --oneline
Quick summary table of commonly used Git commands for daily use.
Command | Purpose |
| Start a new Repository |
| Copy remote repository |
| Check current state |
| Stage changes |
| Save changes |
| Manage branches |
| Switch branches |
| Combine branches |
| Upload to remote |
| Download update |
| Roll back |
| Undo safely |
| Remove files |
A Basic Developer Workflow Using Git (Beginner-Friendly)
When developer start working on a new project, git becomes the safety net. It keeps track of what a developer build, save checkpoints, and allows you to undo mistekes easily.

Here is the simple and practical workflow that beginners can follow:
Step 1: Create a New Project Folder
Start by making a folder for your project.
Example:
mkdir myproject
cd my project
Step 2: Initialize Git
Tell Git to start tracking this folder.
git init
A hidden .git folder is created — this is the local repository where Git stores history.
Step 3: Create or modify Files
Add some files:
echo "helo git" >index.txt
your working directory now has untracked changes.
Step 4: Check Your Project Status
git status
You will see:
New Files
Modified Files
Files not yet staged
Step 5: Stage your changes
Tell git which changes you want to include in the next commit.
git add index.txt
To add everything
git add .
Step 6: Commit Your Changes
Save a snapshot of your work:
git commit -m "initial commmit: added index file"
Project has now the first entry in the history.
Conclusion:
Git gives developers a structured way to track changes and collaborate safely. It works through a simple flow: working directory → staging area → repository. Commands like git init, git status, git add, git commit, and git log form the core of everyday use. Repositories store complete project history, commits create snapshots, branches allow parallel work, and HEAD marks your current position. A basic workflow—edit, stage, commit, repeat—helps beginners build confidence. Git keeps projects organized, prevents mistakes, and supports efficient teamwork. It’s a must-know tool that transforms how developers manage and maintain code.
Let’s connect, Social Media Profile:
X :https://x.com/nitishhpandey
Linkdln: https://www.linkedin.com/in/nitishhpandey/
Instagram: https://www.instagram.com/nitishhpandey/

