Git for Beginners: Basics and Essential Commands
Git is one of the most important tools a developer must learn. It helps manage code changes, avoid mistakes, and collaborate efficiently.
This blog explains what Git is, why it’s used, core Git concepts, and essential commands, with a simple workflow that beginners can easily follow.
What is Git ?
Git is a distributed version control system that records changes in code and allows developers to manage different versions of a project.
Git helps you manage changes to your code over time. It keeps track of every little change or update you make, you can always look back at previous versions or undo mistakes if needed.
Why does Git exists ?
When writing code, files change constantly. Without a system like VCS, it becomes difficult to :
track changes or undo mistakes.
Work on new features without breaking existing code.
Collaborate with other developers
Git solves these problems by giving developers control while working on code.
Git Basics and Core Terminologies
Before using Git commands, it’s important to understand a few core concepts.
Repository : A repository (repo) is a project folder tracked by Git. It contains Project files and the hidden
.gitfolder.Commit : A commit is a snapshot of the project at a specific point in time.
Each commit includes: the changes made, a unique id, and the meesage describing the changes.
Branch : A branch is a separate line of development. the repo can have more than one branches.
Head :
HEADis a pointer that indicates the current commit or branch you are working on.
Common git commands
git init: Initialize a Repository.git init
Creates a new Git repository by adding a .git directory to the project.
git status: Shows modified, staged, and untracked files.git status
git add <file_name>: Moves selected changes to the staging area.git add <file_name> // to stage the single file with <file_name> or git add . // to stage all the changed files
git commit: save changes from the staging area.git commit -m "commit_message"
git log: log the commit historygit log // detailed commits or git log --oneline // details in one line related to commits
Understanding the Git Workflow

git initThis command converts a normal folder into a Git-tracked repository. Git creates a hidden
.gitdirectory. From this point, Git starts monitoring changes.Working Directory
The
working directoryis your project folder where you write code, edit files or delete or modify content.At this stage:
Gitsees the changes but nothing is saved yet.git add <file_name>This moves selected changes to the staging area . You decide exactly what will be included in the next commit.
Staging Area
The staging area is a temporary holding space.
git commit -m “<commit_message>“This command creates the commit. The commit is stored in the local repository. Each commit becomes part of the project history.
git push origin <branch_name>
Uploads local commits to a remote repository (GitHub, GitLab, etc.) Used for collaboration and backups
Until you push, your code exists only locally.

Let’s Connect
If you’re also learning Git or just starting your developer journey, feel free to connect with me.
🔗 Github
Happy coding guys…



