Skip to main content

Command Palette

Search for a command to run...

Git Explained: What It Is, Why You Need It, and How to Get Started

Updated
4 min read
Git Explained: What It Is, Why You Need It, and How to Get Started
T

B.Tech student at NIT Jalandhar, currently learning web development and actively upskilling in frontend fundamentals. Exploring HTML, browser behavior, and how the web works behind the scenes, with a focus on building strong basics. I believe in consistent learning, understanding systems deeply, and improving step by step. Documenting my journey, building projects, and growing toward tech-driven roles through hands-on practice 🚀

Git is a distributed version control system, which means every developer has a full copy of the project and its history on their own computer. It helps track changes in code, save different versions, and go back to older versions if something breaks. Because Git works locally, you can commit changes, create branches, and experiment safely even without the internet. This makes development faster, safer, and perfect for both solo work and team collaboration.

We need a Version Control System (VCS) because it helps developers manage code safely, clearly, and collaboratively.

Without VCS, code is shared using files, folders, or pen-drives, leading to confusion like multiple “final” versions, lost changes, and accidental overwrites. There is no clear history, no easy rollback when something breaks, and teamwork becomes messy.

A VCS solves this by tracking every change, showing who changed what and when, allowing you to go back to any previous version, and enabling multiple people to work on the same project without conflict. It also keeps code backed up and organised.


Basic terminology of GIT :

REPOSITORY

A repository is the place where your project lives along with its entire history. It contains all files, changes, and versions of the code. A repository can exist on your computer (local repository) or online (remote repository like GitHub).


COMMIT

A commit is a saved snapshot of your project at a specific point in time. Each commit records what changed, when it changed, and includes a message explaining the change. Commits help you move backward or forward in your project’s history.


BRANCH

A branch is an independent line of development. It allows you to work on new features or fixes without affecting the main code. Once the work is complete, branches can be merged back into the main branch.


HEAD

HEAD is a pointer that tells Git where you are currently working. It usually points to the latest commit on the current branch. When you switch branches or move between commits, HEAD updates automatically.


CLONE

Clone is used to create a complete local copy of a remote repository. It downloads the project files along with the entire commit history, so you can start working on the project on your own machine.


PUSH

Push sends your local commits to a remote repository such as GitHub. It updates the shared codebase so others can see and use your changes.


PULL

Pull fetches the latest changes from the remote repository and merges them into your local branch. It helps keep your local code up to date with what others have pushed.


MERGE

Merge combines changes from one branch into another. It is commonly used to add completed features or fixes from a separate branch into the main branch.


MOSTLY USED GIT COMMANDS :

1) git init

Initializes Git in a folder and starts version tracking for the project.

git init

2) git status

Shows the current state of files, including untracked, modified, and staged files.

git status

3) git add

Moves selected changes to the staging area so they can be included in the next commit.

git add index.html
git add .

4) git commit

Saves a snapshot of the staged changes into the local repository with a description.

git commit -m "Add homepage layout"

5) git log

Displays the history of commits made in the repository.

git log

Simple Flow to Remember :

git init → git status → git add → git commit → git log
  1. git init: Initialises a new Git repository in your project folder, starting version tracking.

  2. git status: Displays the current state of the working directory and staging area, showing which files are untracked, modified, or staged for commit.

  3. git add: Moves changes from the working directory to the staging area, preparing them to be included in the next commit.

  4. git commit: Saves a snapshot of the staged changes to the local repository, along with a commit message describing the changes.

  5. git log: Shows the commit history, listing all the commits made in the repository, including details like commit hashes, author, date, and commit messages.


SUMMARY

Git simplifies how developers manage code by tracking changes, saving versions, and enabling safe collaboration. Instead of messy file copies, Git lets you work freely, commit meaningful updates, share work through GitHub, and stay in sync with others—making development organized, reliable, and beginner-friendly.