Git & GitHub

SaileshSailesh
3 min read

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:

  1. Working Directory → Where you make changes to files.

  2. Staging Area → Where you prepare changes before saving them.

  3. 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:

  1. Use Git to track changes on your computer.

  2. Push (upload) your Git repository to GitHub.

  3. Invite teammates—they clone (download) the project.

  4. Everyone works on their own copies, then pushes changes back.

  5. Git keeps everything in sync.


5. Basic Git Commands You Should Know

CommandWhat it DoesExample
git initStart a new Git repositorygit init
git statusCheck what’s changedgit status
git add filenameStage a file for commitgit add index.html
git commit -m "message"Save a versiongit commit -m "Added homepage"
git pushUpload to GitHubgit push origin main
git pullDownload changes from GitHubgit pull origin main
git clone urlCopy a repository from GitHubgit 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.

0
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