Learn Git in 15 Minutes: Quick Start Guide

If you're working on any software project, knowing Git is non-negotiable. It’s the most popular version control system developers use to track changes, collaborate with others, and avoid breaking things.
You don’t need to memorize everything to start using Git. In this guide, you'll learn the most essential Git commands and concepts to get you productive fast.
What Is Git?
Git is a tool that tracks the history of your project. You can go back to previous versions, work on multiple features at the same time, and collaborate without fear of losing code.
Think of it as your project's time machine.
Install Git (If You Haven’t Yet)
Visit https://git-scm.com/downloads and install Git for your OS. After installing, confirm it works:
git --version
Set Your Identity
The first time you use Git, configure your name and email:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Create or Clone a Repository
A repository (or repo) is where Git tracks your code.
To start a new one:
git init
To clone an existing repo:
git clone https://github.com/username/repo.git
Track Changes in Files
After editing files, check what's changed:
git status
To stage a file:
git add filename
To stage all files:
git add .
Then commit your changes:
git commit -m "Add feature or fix bug"
Check History
To view previous commits:
git log
Use the arrow keys to scroll and press q
to exit.
Push to GitHub
To send your commits to a remote repo:
git push origin main
If it's your first push:
git push --set-upstream origin main
Pull Latest Changes
To fetch and merge changes from the remote:
git pull
Branching Basics
Branches let you work on features without affecting the main codebase.
Create a branch:
git checkout -b new-feature
Switch back to main:
git checkout main
Merge your feature:
git merge new-feature
Delete the branch:
git branch -d new-feature
Ignore Unwanted Files
Create a .gitignore
file to skip temp or sensitive files:
node_modules/
.env
dist/
Undo Changes (Safely)
Unstage a file:
git reset filename
Discard local changes:
git checkout -- filename
Note: this will permanently remove unsaved changes.
You don’t need to master every Git command to be productive. Stick to init
, add
, commit
, push
, pull
, and branch
until you're comfortable.
Git is one of those tools that becomes easier with practice. This guide gives you a strong starting point to build from and avoid common mistakes as you grow.