What is Git and How Does it Work?
Ad
What is Git?
Git is the world's most popular version control system. It tracks every change to your code, lets multiple people collaborate, and lets you revert mistakes. Created by Linus Torvalds in 2005.
Core Commands
git init # start tracking a project
git add . # stage changes
git commit -m "message" # save a snapshot
git status # see what changed
git log # view history
How Git Works
Git stores snapshots of your project. Each commit is a checkpoint you can return to. Changes move through three areas:
| Area | Command |
|---|---|
| Working directory | your files |
| Staging area | git add |
| Repository | git commit |
Branching
git branch feature # create branch
git checkout feature # switch to it
git merge feature # merge into current branch
FAQs
Git vs GitHub?
Git is the tool; GitHub is a hosting service for Git repositories. More in our Git guides.
Do I need GitHub to use Git?
No — Git works locally. GitHub adds online collaboration.
