Introduction
If you are a software developer, data engineer, SQL developer, or anyone who writes code, learning Git is one of the most important skills you can have.
What is Git?
Git is a Version Control System (VCS).
It helps developers keep track of every change made to their code.
Think of Git as a time machine for your project. If something goes wrong, you can easily return to an older working version.
Why Do We Need Git?
Imagine you're working on a project without Git.
Your project folder might look like this:
Project
Project_Final
Project_Final_New
Project_Final_Latest
Project_Final_Updated
After a few days, you won't even remember which folder contains the latest code.
Git solves this problem by storing every version inside a single project.
Instead of creating multiple folders, Git stores the history internally.
Version 1
↓
Version 2
↓
Version 3
↓
Version 4
You can restore any previous version whenever you want.
What is Version Control?
Version Control means keeping a record of every change made in your project.
Git stores information such as:
Who made the change
When the change was made
What files changed
Why the change was made
This makes collaboration much easier.
Git vs GitHub
One of the biggest beginner mistakes is thinking Git and GitHub are the same.
Git | GitHub |
|---|---|
Software installed on your computer | Cloud platform for hosting repositories |
Works offline | Requires internet for synchronization |
Tracks file changes | Stores repositories online |
Manages version history | Enables collaboration |
Workflow
Laptop
│
▼
Git
│
▼
GitHub
Git manages your code locally, while GitHub stores a copy online.
Important Git Terminology
Repository (Repo)
A Repository is simply your project folder that Git manages.
Example:
EmployeeManagement
or
ReadDocumentAI
Every Git project is called a Repository.
Commit
A Commit is like saving a checkpoint.
Whenever you finish a logical piece of work, you create a commit.
Think of it like SQL Server:
BEGIN TRANSACTION
UPDATE Employee
SET Salary = Salary + 5000
COMMIT
Similarly, in Git:
git commit
Once committed, your changes become part of the project's history.
Branch
A Branch is an independent line of development.
By default, every repository starts with:
main
Suppose you're working on new features.
main
feature-login
feature-dashboard
bug-fix
Each developer works on a separate branch without affecting the main project.
Clone
Clone means downloading an existing repository.
GitHub
│
▼
Your Computer
Command:
git clone repository-url
Push
Push uploads your local commits to GitHub.
Laptop
│
▼
GitHub
Pull
Pull downloads the latest changes from GitHub.
GitHub
│
▼
Laptop
Understanding the Git Workflow
Every Git project follows the same workflow.
Create or Modify File
│
▼
git add
│
▼
git commit
│
▼
git push
This simple cycle is repeated throughout development.
Installing Git
After installing Git, verify the installation.
git --version
Example:
git version 2.49.0
Configure Git
Before using Git, configure your username and email.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Verify your configuration:
git config --list
Creating Your First Git Repository
Create a project folder.
GitDemo
Open Terminal or Command Prompt.
cd GitDemo
Initialize Git.
git init
Output:
Initialized empty Git repository
Git creates a hidden folder called:
.git
This folder stores the complete version history of your project.
Create Your First File
Create a file named:
README.md
Add some text.
Hello Git
Check Repository Status
Run:
git status
Output:
Untracked files:
README.md
This means Git has detected the file, but it is not yet being tracked.
Understanding Git's Three Stages
This is one of the most important Git concepts.
Working Directory
│
▼
Staging Area
│
▼
Repository
Or simply:
File
↓
git add
↓
Staging Area
↓
git commit
↓
Repository
Working Directory
Where you create or edit files.
Staging Area
Where you tell Git which changes should be included in the next commit.
Repository
Where Git permanently stores your commits.
Stage Your Changes
Add a single file:
git add README.md
Add every modified file:
git add .
Create Your First Commit
git commit -m "Initial commit"
Example Output:
1 file changed
create mode 100644 README.md
Congratulations! Your first Git commit has been created.
View Commit History
Display the complete history.
git log
Compact version:
git log --oneline
Example:
a8f22 Initial commit
Beginner Commands Summary
Command | Purpose |
|---|---|
| Check Git installation |
| Initialize a repository |
| Check repository status |
| Stage changes |
| Save changes |
| View commit history |
| Compact commit history |
Common Beginner Mistakes
Forgetting to run
git addbefore committing.Writing unclear commit messages like "Update" or "Fix".
Committing unfinished work.
Confusing Git with GitHub.
Ignoring
git status, which is one of the most useful commands.
What's Next?
Now that you've learned the basics, the next topics are:
Git Ignore (
.gitignore)Git Diff
Git Restore
Git Reset
Git Branch
Git Merge
GitHub Repositories
Git Push and Pull
Merge Conflicts
Pull Requests (PRs)
Mastering these concepts will prepare you for real-world software development and technical interviews.
Conclusion
Git is not just a collection of commands—it is a system for managing your project's history safely and efficiently.
Once you understand the workflow:
Working Directory
↓
git add
↓
Staging Area
↓
git commit
↓
Repository
↓
git push
↓
GitHub
you'll find that Git becomes an essential part of your daily development workflow.