DEV Community

saiyam gupta
saiyam gupta

Posted on

Git for Beginners

Git for Beginners: Simple, Clear, and Practical Guide

If you are learning development, Git is not optional — it is essential. Don’t worry though. Git is much simpler than it looks once you understand the basics.

This blog explains Git in a human, easy, and practical way, with simple examples you can actually use.


What is Git?

Git is a tool that helps you save, track, and manage changes in your code.

In simple words:

Git remembers every version of your project so you can move forward or go back anytime.

Think of Git like:

  • A save button with history
  • A backup for your code
  • A tool that lets many people work together safely

Why Git is Used?

Git makes a developer’s life easier.

  • You can undo mistakes
  • You can see who changed what
  • You can work on new features without breaking existing code
  • You can collaborate with a team smoothly

That’s why almost every company uses Git.


Core Git Concepts (Very Simple)

Repository (Repo)

A repository is just your project folder that Git is tracking.

Inside it, Git stores all change history.


Commit

A commit is a saved version of your code.

You can think of it as:

“I like the current state of my project. Save it.”

Example:

Added homepage UI
Enter fullscreen mode Exit fullscreen mode

Branch

A branch is a separate copy of your code to work safely.

  • main → stable code
  • feature-login → new work

Branches let you experiment without fear.


HEAD

HEAD tells Git where you are right now.

It points to the current commit you are working on.


Git’s 3 Important Areas

Working Directory → Staging Area → Repository
Enter fullscreen mode Exit fullscreen mode
  • Working Directory: where you edit files
  • Staging Area: where you prepare files
  • Repository: where commits are stored

Common Git Commands (You’ll Use These Daily)

Start Git in a Project

git init
Enter fullscreen mode Exit fullscreen mode

Check What’s Changed

git status
Enter fullscreen mode Exit fullscreen mode

Add Files to Git

git add index.html
git add .
Enter fullscreen mode Exit fullscreen mode

Save Your Changes

git commit -m "Initial setup"
Enter fullscreen mode Exit fullscreen mode

See Past Saves

git log --oneline
Enter fullscreen mode Exit fullscreen mode

A Real Developer Workflow (From Scratch)

mkdir my-project
cd my-project
git init
Enter fullscreen mode Exit fullscreen mode

Create a file → edit it → then:

git add .
git commit -m "Add first version"
Enter fullscreen mode Exit fullscreen mode

Make changes → repeat the same steps.

This is exactly how developers use Git daily.


How Git History Looks

Commit A → Commit B → Commit C (HEAD)
Enter fullscreen mode Exit fullscreen mode

With branches:

main ── A ── B
          \
           C ── D (feature)
Enter fullscreen mode Exit fullscreen mode

Project Structure (Simple View)

Project Folder
 ├── Your files (working directory)
 └── .git (Git history)
Enter fullscreen mode Exit fullscreen mode

Final Thoughts

Git is not hard — it’s just new.

If you understand:

  • what a commit is
  • how to add and save changes
  • and the basic workflow

You already know 80% of Git.

Practice a little every day, and Git will feel natural very quickly.

Happy coding 🚀

Top comments (0)