Skip to main content

Command Palette

Search for a command to run...

Getting Started with Git: A Beginner-Friendly Guide 🚀

Published
•3 min read

If you’ve just started learning development, you’ve probably heard people say things like “push it to Git” or “check the commit history”.
At first, Git can feel confusing — but once you understand why it exists and how it works, it becomes one of the most powerful tools in your developer journey.

What is Git?

Git is a distributed version control system.

In simple words 👉 Git helps you track changes in your code over time.

Think of Git as a time machine for your project:

  • You can save different versions of your code

  • Go back to older versions if something breaks

  • Work on new features without touching stable code

  • Collaborate with others without overwriting each other’s work

Why Git is Used?

Before Git, developers used:

  • Pendrives

  • Emails

  • ZIP files

  • Shared folders

This caused many problems:

  • Code got overwritten

  • No idea who changed what

  • No history of changes

  • Collaboration was painful

Git solves all of this by:

  • Keeping a complete history of changes

  • Allowing multiple developers to work together

  • Making experiments safe using branches

  • Helping teams track bugs and fixes easily

👉 Today, Git is an industry standard, used by startups and big tech companies alike.

Git Basics and Core Terminologies

1. Repository (Repo)

A repository is simply a project folder that Git is tracking.

Once a folder becomes a Git repository, Git starts monitoring every change inside it.

2. Commit

A commit is a snapshot of your code at a specific point in time.

3. Branch

A branch lets you work on a new feature without disturbing the main code.

  • main → stable production code

  • feature-login → new feature being developed

Once everything works, branches can be merged.

4. HEAD

HEAD is simply a pointer that tells Git:

“This is the current commit you are working on.”

Most of the time, HEAD points to the latest commit of the current branch.

Common Git Commands:-

1. git init

Initializes a new Git repository.

git init

👉 Converts a normal folder into a Git-tracked project.


2. git status

Shows the current state of your repository.

git status

It tells you:

  • Which files are new

  • Which files are modified

  • What is staged for commit

3. git add

Adds files to the staging area.

git add index.html

Or add everything:

git add .

👉 Staging means: “I want these changes in my next commit.”

4. git commit

Saves your staged changes with a message.

git commit -m "Created basic homepage layout"

Always write clear and meaningful messages.


5. git log

Shows the history of commits.

git log

You can see:

  • Commit ID

  • Author

  • Date

  • Commit message

6. git branch

Check available branches.

git branch

Create a new branch:

git branch feature-navbar

7. git checkout

Switch between branches.

git checkout feature-navbar

A Basic Developer Workflow Using Git

Here’s a realistic beginner workflow 👇

  1. Create a project folder

  2. Initialize Git

     git init
    
  3. Create or edit files

  4. Check status

     git status
    
  5. Add changes

     git add .
    
  6. Commit changes

     git commit -m "Initial project setup"
    
  7. Repeat steps 3–6 as you develop features

That’s it! This loop is what developers follow every single day.