Most people meet version control the hard way: a folder full of report-final.docx, report-final-v2.docx and report-final-REALLY-final-John-edits.docx, and nobody sure which one is the real one. Git is the grown-up answer to that folder, and GitHub is where most of the world keeps its Git projects. This website reaches you through it: every change to these pages is a branch, a pull request and a merge on GitHub before it goes live. Here is how it all works, one picture at a time.

Git and GitHub are two different things

The names cause most of the confusion, so start here.

  • Git is free, open-source software that runs on your own computer. Point it at a folder and it records every saved version of every file in it, who changed what, when, and why. Linus Torvalds wrote it in April 2005 to manage the Linux kernel, after the tool the kernel developers had been using was withdrawn. (He has joked that he names his projects after himself; “git” is British slang for an unpleasant person.)
  • GitHub is a website, launched in 2008 and bought by Microsoft in 2018, that stores copies of Git projects online and adds the tools people need to work on them together: pull requests, code review, issue tracking, automation and web hosting.

Git is distributed. That means there is no single master copy that everyone has to log in to: every computer that works on a project holds the entire history. GitHub is simply the copy everyone agrees to meet at.

Git on each computer, GitHub in the middleTwo computers, yours and a colleague's, each hold a full copy of the project and its history, kept by Git. Above them is GitHub, holding a shared copy online plus issues, reviews and pull requests. Each computer pushes its new commits up to GitHub and pulls the other person's commits down.GitHubthe shared copy, online+ issues, reviews, pull requestsYour computerGit keeps the full historyA colleague’s computertheir own full copypushsend yours uppullbring theirs downGit does the tracking on every computer. GitHub is where the copies meet.
The tool and the meeting place. Each computer has its own complete copy, history and all, managed by Git. Changes travel through GitHub: you push your new work up, and pull everyone else’s down.

A project tracked by Git is called a repository, or repo. On your computer it looks like a normal folder. The only difference is a hidden .git folder inside it, where Git keeps the history.

The commit: a saved snapshot with a note attached

The basic unit of Git is the commit. When you make a commit you are telling Git, “remember the project exactly as it is right now”. Each commit records:

  • a snapshot of every file in the project at that moment (Git is clever about storage: files that didn’t change aren’t stored twice);
  • who made it, and when;
  • a short message saying why, such as “Fix a typo on the pricing page”;
  • and the ID of the commit that came before it, its parent.

That last item is what turns a pile of snapshots into a history. Each commit points back to its parent, so the commits form a chain all the way back to the first one.

Four commits in a chainFour commit cards from oldest to newest, each showing a short ID such as a1f3c9e, a message such as Add home page, and who made it and when. Every commit after the first stores a snapshot plus the ID of its parent, drawn as an arrow pointing back to the previous card. A label called main points at the newest commit.a1f3c9eAdd home pageJohn · 3 Octfirst commit7be0d42Fix a typoAva · 4 Octsnapshot + parent IDc4592afNew team photoNoah · 6 Octsnapshot + parent ID3f7a9c1Update pricesJohn · 9 Octsnapshot + parent IDmainoldest← each arrow points to the parentFollow the arrows back and every earlier version can be rebuilt exactly.
History is a chain. Each commit stores a snapshot and its parent’s ID. main is just a label pointing at the newest commit; when a new commit is made, the label moves forward to it.

Because every version is kept, you can open any old commit and see the project exactly as it was, compare two versions line by line, or undo a single change made three months ago without disturbing anything since.

Where the strange IDs come from

Commits aren’t numbered 1, 2, 3. Each one is named by a hash: a fingerprint calculated from everything inside the commit, written as 40 letters and digits such as 3f7a9c1e0b84d2…. People usually quote just the first seven characters. By default Git calculates it with an algorithm called SHA-1; Git 3.0 is planned to switch new repositories to the stronger SHA-256. (We explain how hashes work in how a computer knows a file isn’t broken.)

How a commit gets its IDA commit is made of four things: the snapshot of every file, the parent commit's ID, the author and time, and the message. These go through a hash function, SHA-1, which produces the commit's ID, 40 characters long, starting 3f7a9c1e0b84d2. Below, the same commit with one comma changed hashes to a completely different ID starting b02d55e7. Because every later commit includes its parent's ID, all of their IDs would change too, so history is very hard to rewrite unnoticed.What goes into one commit• the snapshot of every file• the parent commit’s ID• author, email, date and time• the messagehashSHA-1the commit’s ID3f7a9c1e0b84d2…40 characters in fullSame commit, one commachanged in one filehash againb02d55e7c41a9f…nothing like the old IDEvery later commit includes this ID, so their IDs all change too.That is why history is very hard to rewrite unnoticed.
An ID that’s very hard to fake. Change a single character and the commit’s fingerprint changes completely. Because each commit includes its parent’s ID, the change ripples through every later commit too.

This has a useful side effect: a Git history is tamper-evident. If anyone altered an old commit, its ID and the ID of every commit after it would change, and every other copy of the repository would immediately disagree. It also means two copies of a project can work out exactly which commits they share just by comparing IDs, which is how push and pull know what to send.

Three places a change lives on your computer

Git doesn’t save every keystroke. You choose when to commit, and you choose what goes into each commit. To make that possible, a change passes through three places on your computer before it reaches GitHub.

Where a change travels: folder, staging area, repository, GitHubFour boxes left to right. On your computer: the working folder, holding the files you edit as normal; the staging area, holding the changes picked for the next commit; and the local repository, the hidden .git folder holding your saved commits. Then GitHub, the shared copy. git add moves changes from the folder to staging, git commit saves them into the repository, and git push sends commits to GitHub. git pull comes back the other way, bringing other people's commits down into your folder.on your computerWorking folderthe files youedit, as normalStaging areachanges chosenfor the next commitLocal repositoryyour saved commits,in the .git folderGitHubthe copy everyonesharesgit addgit commitgit pushgit pull: fetch other people’s commits and bring your folder up to date
Edit, pick, save, share. You edit files as normal. git add picks which changes belong in the next commit, git commit saves them to your local history, and git push sends your new commits to GitHub. git pull brings other people’s commits back down.
  1. The working folder. The files you open and edit with your normal programs. Git leaves them alone until you ask it to switch branch or pull.
  2. The staging area. A holding pen for the next commit. If you fixed a typo and also started a half-finished new section, you can stage just the typo fix and commit it on its own, with its own message.
  3. The local repository. Your saved commits, inside the hidden .git folder. Committing is instant and works with no internet connection at all.

Only push sends your work to GitHub. Until you push, your commits exist only on your computer, which is worth remembering before a laptop goes in for repair.

Branches: a safe place to try something

A branch is a separate line of commits that splits off from the main history. You can make as many commits on it as you like, and none of them touch main until you decide they should. Under the hood a branch is nothing more than another label pointing at a commit, like the main label in the chain above, so branches are instant and cost almost nothing.

The usual habit is one branch per job: a new page, a bug fix, an experiment. If the experiment fails, you delete the branch and main never knew it existed. If it works, you merge it.

A branch splits off main and is merged backThe main line runs left to right through commits labelled start, logo, menu fix and urgent fix. After menu fix, a branch called new-services-page splits off below with two commits of its own, draft page and add photos. Main keeps moving with the urgent fix while the branch is worked on. Then a merge commit on main joins the two lines, bringing the branch's work into main.mainnew-services-pagestartlogomenu fixurgent fixmergedraft pageadd photosbranch offtime
Work in parallel, combine later. The new page is drafted on its own branch while main carries on, here with an urgent fix. The merge commit at the end has two parents and brings both lines of work together.

Merging is usually automatic. Git compares the changes line by line, so if one person edited the top of a file and another edited the bottom, both edits are simply combined. Only when two branches changed the same lines does Git stop and report a merge conflict. It marks both versions in the file and waits for a person to choose. That’s a feature: Git never silently picks a winner.

The main branch was traditionally called master, and plenty of older projects, including our own website, still use that name. GitHub has named it main in new repositories since 2020, and Git 3.0 is planned to do the same. It works exactly the same either way.

Pull requests: how a team agrees on a change

Git itself has no idea who is allowed to merge what. That social layer is GitHub’s biggest contribution, and its centrepiece is the pull request (GitLab calls the same thing a merge request). A pull request is a page on GitHub that says: “here is my branch; please review it and merge it into main.”

The pull request cycle in six stepsStep 1, make a branch, a safe place to work. Step 2, commit and push, sending the branch up to GitHub. Step 3, open a pull request, which asks for the branch to be merged, and the reviewer is notified. Step 4, review and checks: people comment and automatic tests run. If changes are asked for, a dashed arrow goes back to step 2 to fix and push again. Step 5, merge: the branch joins main. Step 6, optionally, deploy: it goes live.1Make a brancha safe place to work2Commit & pushsend the branch up3Pull request“please merge this”4Review & checkscomments, tests run5Mergethe branch joins main6Deployoptional: it goes livechanges asked for:fix and push againrevieweris notified
The everyday loop. Work happens on a branch, the pull request invites review, and nothing reaches main until it has been looked at. If the reviewer asks for changes, you push more commits to the same branch and the pull request updates itself.

On the pull request page, reviewers see exactly which lines changed, with old and new side by side. They can comment on a specific line, ask for changes or approve. Automatic checks can run at the same stage: tests, spelling, a build of the website. GitHub shows a green tick or a red cross next to each one. The project owner can make those rules compulsory. Branch protection can require an approval and passing checks before anyone can merge into main, and, if “Do not allow bypassing” is ticked, the owner too. (On a private repository, branch protection needs a paid plan, GitHub Pro or Team; on the free plan it covers public repositories only.)

This is the loop this page went through. It was written on its own branch, opened as a pull request, reviewed, and only went live once it had been merged and deployed.

Forks and clones: copying a project

Two words for copying come up constantly, and they mean different things.

  • Clone means downloading a repository from GitHub to your computer, with its full history, so you can work on it. If you have permission to the original, you clone it, branch, push and open pull requests directly.
  • Fork means making your own copy of someone else’s repository on GitHub, under your account. It’s how strangers contribute to open-source projects they have no permission to change.
Fork, clone, push, pull requestOn GitHub, the original project belongs to someone else: you can read it but not change it. Step 1, fork, makes your own copy on GitHub under your account. Step 2, clone, copies your fork down to your computer, where you edit. Step 3, push, sends your commits back up to your fork. Step 4, a pull request from your fork asks the original project to take your change.on GitHubThe original projectsomeone else’s repositoryyou can read it, not change itYour forkyour own copy on GitHub,under your account1 forkYour computerwhere you actually edit2 clone3 push4 pull request
Contributing to someone else’s project. Fork it on GitHub, clone your fork to your computer, push your work back to the fork, then open a pull request asking the original to take it. The owner decides whether it goes in.

Forking is why open source scales. Anyone can propose a fix to a project used by millions without the maintainers handing out keys. They review the pull request and accept it or not. Our own audio player, Ironbark, is public on GitHub for exactly this reason: anyone can read the code, fork it, and suggest a change.

What GitHub adds on top of Git

Pull requests are the headline feature, but most teams end up using several of the others too:

FeatureWhat it does
IssuesA to-do list and bug tracker attached to the project. Issues can be assigned, labelled and closed automatically by the pull request that fixes them.
ActionsAutomation that runs on GitHub’s computers when something happens, such as running the tests on every pull request or publishing a new version when a release is tagged.
PagesFree hosting for a static website straight from a repository (from public repositories on the free plan).
ReleasesPackaged, downloadable versions of a project with release notes, such as an installer for version 1.2.
Security alertsWarnings when a project depends on a library with a known vulnerability (free everywhere), and scanning that catches many accidentally committed passwords and keys (automatic on public repositories; on private ones it’s a paid add-on).
CopilotGitHub’s AI assistant, which suggests code in your editor and can draft pull requests and reviews. It is a separate product with its own plans.

The handful of commands that do almost everything

You don’t need to memorise Git. GitHub Desktop and editors like Visual Studio Code put buttons on all of this, and small edits can be made straight in the browser. But if you see these in a guide, here is what they mean:

CommandIn plain English
git clone <address>Download a repository and its full history.
git statusWhat have I changed, and what’s staged?
git switch -c new-pageMake a new branch called new-page and move onto it.
git add about.htmlStage this file’s changes for the next commit.
git commit -m "Add team photo"Save the staged changes as a commit with that message.
git pushSend my new commits to GitHub.
git pullFetch everyone else’s new commits and merge them into mine.
git logShow the history, newest first.
git diffShow exactly which lines changed.

What Git is not good at

Git was built for text: code, web pages, configuration, documentation. It can tell you that line 42 of a page changed. It works less well with:

  • Big binary files. Videos, Photoshop files and disk images can’t be compared line by line, and every version is stored in full, so the repository balloons. GitHub refuses individual files over 100 MB. Git LFS (Large File Storage) exists for this, but often a different tool is the right answer.
  • Word and Excel files. Git will happily keep every version, but it can’t show what changed inside them or merge two people’s edits. For office documents, the version history built into Microsoft 365 or Google Drive does that job better.
  • Secrets. Passwords, API keys and customer data must never be committed. Deleting a secret in the next commit doesn’t remove it: it’s still in the history, on every clone. If it happens, treat the key as leaked and replace it. Then keep secrets in a separate file that Git is told to ignore, which is what .gitignore is for.

What this means for your business

If anyone in your business writes code, builds websites or keeps technical documentation, they should be using Git. GitHub’s free plan covers unlimited private repositories, which is enough to start. Three settings matter more than the rest: keep repositories private unless you mean to publish them, turn on branch protection so nothing reaches main without a review (for private repositories that needs GitHub Pro or Team, a few dollars a user a month), and make sure no passwords or keys are in the history. Remember too that GitHub is a second copy, not a full backup. Someone with access can still delete a repository, so anything important deserves one more copy somewhere else.

Talk to us about setting it up See Ironbark on GitHub

Common questions

Is Git the same thing as GitHub?
No. Git is free software on your own computer that records the history of a folder. GitHub is a website, owned by Microsoft, that stores Git projects online and adds pull requests, reviews, issues and automation. You can use Git without GitHub, and GitLab, Bitbucket and Codeberg host Git projects too.
Is GitHub free?
For most people and small teams, yes. The free plan includes unlimited public and private repositories and unlimited collaborators. Paid plans add more automation minutes, more storage and organisation-level admin and security controls. Check GitHub’s pricing page for current limits; they change.
Do I need to be a programmer?
No. Git works on any text, so documentation, websites and even books are kept in it. GitHub Desktop and Visual Studio Code give you buttons for commit, push, pull and branch, and small edits can be made in the browser on github.com.
Is my code private on GitHub?
Only if the repository is set to private. A public repository, including its entire history, can be read by anyone. Either way, never commit passwords or keys. Deleting them later leaves them in the history, so a leaked key must be cancelled and replaced.
What’s the difference between a fork and a clone?
A fork is your own copy of someone else’s repository, made on GitHub under your account. A clone is a copy downloaded to your computer so you can edit it. Contributors usually fork, clone the fork, push to it, then open a pull request to the original.
What happens if two people change the same file?
Usually nothing bad. Git merges line by line, so edits to different parts of a file combine automatically. Only when both people changed the same lines does Git report a merge conflict and ask a person to choose.
Is GitHub a backup?
It’s a second copy in another place, which helps, but not a whole backup plan. Anyone with write access can delete a branch or a repository, and a bad change pushed to GitHub is stored there faithfully. Protect main (on private repositories that’s a paid-plan feature), keep another copy of anything important, and remember that files you never committed aren’t on GitHub at all.

Keep learning

Data & encoding How a computer knows a file isn’t broken Parity, checksums and the hashes Git uses to name every commit. Our software Ironbark Our open-source audio player, developed in public on GitHub. Learn All lessons Plain-English explanations of the fundamentals that don’t go out of date.