Introduction to Git
Git is a distributed version control system — it tracks every change to your code, lets you revert to any previous state, and enables multiple people to collaborate without overwriting each other's work. It was created by Linus Torvalds (the creator of Linux) in 2005.
Git vs GitHub
These are different things:
- Git is the tool that runs on your computer and tracks changes.
- GitHub (and GitLab, Bitbucket) is a hosting service that stores Git repositories online and adds collaboration features (pull requests, issues, CI/CD).
You can use Git entirely offline. GitHub is just a place to host and share your Git repositories.
Setup
Configure your identity once (it's attached to every commit you make):
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Creating a repository
# Start tracking a new project
git init
# Or copy an existing remote repository
git clone https://github.com/user/repo.git
git init creates a hidden .git folder that stores the entire history and configuration.
Checking status
The command you'll run most often shows what's changed:
git status
It tells you which files are modified, staged, or untracked.
.gitignore
List files Git should never track — dependencies, build output, secrets:
node_modules
.env
.next
dist
*.log
Never commit secrets (API keys, passwords) or large generated folders like node_modules. Add them to .gitignore before your first commit.
Watch & Learn
A recommended video to watch alongside this chapter.
More “Introduction to Git” videos on YouTube