What is Git?
Git is the version control tool used by almost every software team on earth. Here is what it does and why it matters for anyone building software.
Git was created by Linus Torvalds in 2005 to manage development of the Linux kernel after the previous version control tool lost its free license. It was designed for speed, distributed workflows, and handling large codebases. Today it is used by virtually every software project regardless of size.

Git lives on your computer
Unlike most tools you use, Git does not run in the browser. It runs locally on your machine. When you use Git, you are working with a database of changes stored in a hidden folder called .git inside your project.
This means:
- Git works offline, you can commit, view history, and switch branches without internet
- Every developer has the complete project history on their machine
- There is no single server that, if it fails, blocks everyone’s work
When you push to GitHub, you are syncing your local history to a remote copy. The history itself lives with you.
The key concepts
Repository (repo)
A repository is a project folder that Git is tracking. When you run git init inside a folder, Git creates the .git database and starts recording changes. When you git clone a repository, you get a full copy including the entire history.
Commit
A commit is a saved snapshot of your project at a specific point in time. Think of commits as photographs of the codebase, taken whenever you decide. Each commit has:
- A unique SHA hash (like
a3f5c2d8e4) that identifies it permanently - A timestamp
- The author’s name and email
- A message describing what changed and why
- A pointer to the previous commit (creating the history chain)
Commits are permanent. You cannot quietly edit history without leaving a trace. This is what makes Git a reliable audit trail.
The staging area (index)
Git has an intermediate step between changing files and committing them: the staging area (also called the index). You choose which changes to include in the next commit using git add.
Why? Because you might change three files but only want to commit two. Or you want to commit parts of a file but not all of it. The staging area gives you precise control over what goes into each commit.
Branch
A branch is a separate line of development. The default branch is called main. When you create a branch, you are saying “let me work on this in isolation without touching main.” When done, you merge the branch back.
Teams typically have:
main, production-ready code, always stabledevordevelop, integration branch for features before they go to mainfeature/user-authentication, a specific feature in progressfix/login-bug, a specific bug fix

Merge and rebase
Merging combines changes from one branch into another. Git creates a “merge commit” that has two parents, preserving the full branch history.
Rebasing replays commits from one branch on top of another, producing a cleaner linear history. The trade-off: rebasing rewrites history, which can be confusing if others are using the branch.
For beginners, use merge. Learn rebase later.
The everyday workflow
Most Git usage is four commands:
git add . # stage all changed files
git commit -m "Add user login page" # save a snapshot with a message
git push # send commits to GitHub
git pull # download latest commits from GitHubAnd a few more you will use constantly:
git status # what has changed since last commit?
git log # show the history of commits
git log --oneline # compact view of history
git diff # show exact line-by-line changes
git branch # list branches
git switch -c feature/new-thing # create and switch to a new branch
git switch main # switch back to main
git merge feature/new-thing # merge a branch into current branchWhat to put in a .gitignore file
When you start a project, create a .gitignore file immediately. At minimum:
# Dependencies, never commit these, install from package.json/requirements.txt
node_modules/
.venv/
__pycache__/
# Secrets, NEVER commit these
.env
.env.local
*.key
# System files
.DS_Store # macOS desktop metadata
Thumbs.db # Windows thumbnail cache
# Build output, generated files, not source
dist/
build/
.next/GitHub’s collection of .gitignore templates covers every language and framework. Use the right one for your stack.
Why you need Git even if you are solo
Even without collaborators, Git gives you:
- Complete undo history, every commit is a restore point. The command
git revertundoes any commit non-destructively.git stashsaves work-in-progress changes temporarily. - Safe experimentation, create a branch, try something risky, abandon it if it does not work. Main stays clean.
- Collaboration readiness, when you want help from a developer or AI coding tool, they can read your history to understand what has already been tried.
- Backup, push to GitHub and your code is safe even if your laptop dies.
What Git is not
Git is not GitHub. Git is the tool. GitHub is a website that hosts Git repositories online. You can use Git locally with no internet, with no GitHub account, with no remote at all. GitHub just adds sharing, collaboration, and a web interface on top.
There are also alternatives to GitHub: GitLab (popular for self-hosting and CI/CD) and Bitbucket (common in enterprise Jira-heavy teams).

Further reading
- Pro Git, free official book , the complete reference, well-written, covers everything from basics to internals
- Learn Git Branching, interactive visual tool , the best way to understand branches and merges visually
- Oh Shit, Git! , plain-language recipes for common Git disasters (“I committed to main when I meant to commit to a branch”)
- Git Immersion , guided walkthrough of Git fundamentals
- .gitignore templates, GitHub , official templates for every language
What’s next
Next: What is GitHub? , the platform that hosts Git repositories and where most of the world’s open-source code lives.
Frequently asked questions
