Git & GitHub

If you’ve ever worked on a project and wished you could save every version, easily undo mistakes, and collaborate with others, you’re about to meet two tools that make it all possible: Git and GitHub.
Let’s break them down step-by-step.
1. What is Git?
Think of Git as a time machine for your code.
It’s a version control system—a tool that keeps track of every change you make to your files. With Git, you can:
Save different versions of your work.
Go back to a previous version if something breaks.
Work on new features without affecting the main project.
Merge changes from multiple people into one project.
Example:
Imagine you’re writing a school project. Without Git, if you mess up, you might copy-paste your file as project_final_v2_REAL_FINAL.docx
.
With Git, you just commit your changes, and Git remembers them forever. No extra files needed.
2. How Git Works (In Simple Terms)
A Git project has three main states:
Working Directory → Where you make changes to files.
Staging Area → Where you prepare changes before saving them.
Repository → Where the saved versions live permanently.
Typical Git Workflow:
pgsqlCopyEditYou → Edit files → Stage changes → Commit changes → Push to GitHub
3. What is GitHub?
Git is for tracking changes locally on your computer.
GitHub is like Google Drive for Git projects—it stores your Git repositories online so you can:
Share your code with others.
Collaborate with a team from anywhere.
Show your projects to the world (great for portfolios).
Back up your work so it’s safe.
GitHub adds collaboration features:
Issues → Track bugs and tasks.
Pull Requests → Suggest changes to someone else’s project.
Actions → Automate workflows (like running tests when code changes).
4. How Git & GitHub Work Together
Let’s say you’re building a website:
Use Git to track changes on your computer.
Push (upload) your Git repository to GitHub.
Invite teammates—they clone (download) the project.
Everyone works on their own copies, then pushes changes back.
Git keeps everything in sync.
5. Basic Git Commands You Should Know
Command | What it Does | Example |
git init | Start a new Git repository | git init |
git status | Check what’s changed | git status |
git add filename | Stage a file for commit | git add index.html |
git commit -m "message" | Save a version | git commit -m "Added homepage" |
git push | Upload to GitHub | git push origin main |
git pull | Download changes from GitHub | git pull origin main |
git clone url | Copy a repository from GitHub | git clone https://github.com/user/repo.git |
6. Why Git & GitHub are Essential
Safety: You can always roll back to a working version.
Collaboration: Multiple people can work on the same project.
Portfolio: Show off your projects to employers.
Automation: Integrate with CI/CD tools for deployment.
7. Real-Life Example
Imagine you’re building a Todo List App with a friend:
You create the main structure and push it to GitHub.
Your friend works on the "Add Task" feature while you style the design.
Git keeps both changes separate until you merge them.
No one overwrites the other’s work.
Subscribe to my newsletter
Read articles from Sailesh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sailesh
Sailesh
I am a full stack developer who is looking forward to share the tools and technologies that are used for programming ,to make programming easier