Skip to content

What is Git?

docs.scrimba.com

You have almost certainly done version control by hand. A folder with report.docx, report_final.docx, report_final_v2.docx, and report_final_ACTUAL.docx is version control, of the worst possible kind. You cannot tell what changed between two of those files, you cannot merge edits two people made at the same time, and you definitely cannot get back the good paragraph you deleted three copies ago.

Git solves that problem properly. It is a tool that records snapshots of your project over time, so your whole history lives in one place instead of a pile of copies. The tool itself is a small program that lives on your own computer: you type commands that start with git into a terminal, and it answers in text.

What Git does for you

At its core, Git keeps a timeline of your project. Each time you reach a point worth saving, you record a commit: a snapshot of every file, plus a short message describing what changed and why. Later you can look back over that timeline and see exactly how the project got to where it is. Here is a real timeline, printed by git log, the command that lists a project's commits (the --oneline flag shortens each one to a single line):

bash
$ git log --oneline
a1b2c3d Add password strength meter
9f8e7d6 Fix signup form validation
5c4b3a2 Set up project structure

That is three saved points in a project's history, newest at the top, each with a short ID and the message its author wrote. (In every example like this, the line starting with $ is a command typed into a terminal, without the $ itself, and the lines below it are Git's reply.) You will learn every command that produces and reads this history over the next few chapters. For now the idea to hold onto is that Git is recording your work as a series of snapshots you can always return to.

Once your project has a history like this, a lot becomes possible. You can see what changed and who changed it. You can try a risky idea on the side and throw it away cleanly if it does not work out. You can hand the whole project, with its full history, to someone else. And when two people edit the same code, Git can combine their work and flag the spots where they disagree so a human can settle them. Those four abilities, history, safe experiments, sharing, and combining work, are the whole reason Git runs under almost every professional codebase.

In practice a team leans on that timeline constantly. Every change of any size starts on its own branch, a separate line of history where you can work without disturbing the main code. When the change is ready, someone reviews it, and then it gets merged back into the main branch. Reviewing, branching, and merging are the daily rhythm of working in Git, and they all rest on the snapshot timeline above. The rest of this handbook walks through each piece of that rhythm in the order you meet it.

One detail matters for everything later: each commit stores the complete state of your tracked files, a full snapshot of that moment. People often picture Git saving only the differences between versions, but under the hood every commit holds the whole project. Git keeps that cheap by storing each unique file content once, so a commit that reuses an unchanged file only points at the copy already saved, and a snapshot of a thousand files where one changed does not duplicate the other 999. Each commit also records the ID of the commit that came before it, its parent, which is how Git links snapshots into a history it can walk backwards. That parent link is the backbone of nearly everything else: branches, merges, and history browsing are all built on following those pointers. You will see the full object model in the History and Branches chapters.

JunoWhat Git does for you Git records your project as a series of snapshots called commits, each with a message saying what changed. Once that history exists you can look back over it, experiment safely, share it, and combine work with other people. The pile of final_v2_ACTUAL copies is the problem Git was built to end, and I promise it feels great the first time you delete one.
JunoWhat Git does for you A commit is a snapshot plus a message, and the history is a timeline of them. Day to day you branch off that timeline to make a change, get it reviewed, and merge it back. Keep the mental model of a growing timeline of snapshots in your head; every command you learn is either adding to it or reading from it.
JunoWhat Git does for you Each commit stores the whole project state and points at its parent, which is how Git walks history. Identical file contents are stored once and shared between commits, so snapshots stay cheap. Hold onto the parent-pointer idea, because branches and merges are the same idea wearing different hats.

Git and GitHub are different things

This one trips up nearly everyone at the start, so here it is in plain terms. Git is the version-control tool. It runs on your own computer, it records your commits, and it needs no internet connection and no account to work. GitHub is a website that stores Git repositories online and adds things around them: a place to share your code, review each other's changes, report issues, and collaborate.

The clearest way to feel the difference: you can use Git every day, committing and branching on your laptop, without ever creating a GitHub account. GitHub only enters the picture when you want to put your repository somewhere shared so other people, or other machines, can reach it. Git is the engine; GitHub is one place to host what it produces. Others exist, such as GitLab and Bitbucket, and they all host the same Git repositories underneath.

The reason the two blur together is that most people meet Git and GitHub at the same moment, cloning a project from GitHub on their first day. Many people come away thinking git push means "send to GitHub", when it really means "send to whichever remote you configured", and that remote happens to be GitHub most of the time. Keeping the two separate in your head pays off the first time you use Git with a different host, or with no host at all.

JunoGit and GitHub are different things Git is the tool on your computer that records your commits. GitHub is a website that stores Git projects online so people can share and review them. You can use Git with no GitHub account at all. If you remember one thing from this page, make it this one, because mixing them up causes so much early confusion.
JunoGit and GitHub are different things Git is the version-control engine on your machine; GitHub is one popular place to host what it produces, alongside GitLab and Bitbucket. git push sends to whatever remote you set, which is usually GitHub out of habit. Hold the split and you will not be thrown when a project lives somewhere else.
JunoGit and GitHub are different things Git knows about commits, branches, and refs; GitHub layers pull requests, issues, and the merge button on top of a hosted copy. Nothing GitHub adds is a Git command, which is why you open a pull request on a website and never with git. Keep the two apart in your head and most of what looks like GitHub magic turns back into plain refs.

Where Git came from

Git's history explains a lot about why it works the way it does. It was written in 2005 by Linus Torvalds, the same person who started Linux. The Linux kernel is built by thousands of volunteers scattered around the world, and for a few years they had coordinated all that work using a commercial tool called BitKeeper, which the company behind it let open-source projects use for free.

In 2005 that free arrangement fell apart, and the kernel community suddenly had no tool to manage its enormous, fast-moving codebase. Nothing else available at the time could keep up. So Torvalds stepped back from kernel work for a couple of weeks and wrote his own version-control tool, with a few firm goals shaped by exactly that problem.

He wanted it to be distributed, so that every contributor would have the complete project history on their own machine and could work without checking in with a central server. He wanted it to be fast, quick enough to handle a project the size of the kernel without making people wait. And he wanted it to guarantee integrity, so that nobody could quietly alter history and no disk error could corrupt a project without it being noticed.

Those goals are why Git behaves as it does today. When you clone a project you get its entire history to work with, which is the distributed goal in action: you can commit, branch, and browse history on a plane with no wifi. And every commit is stamped with a fingerprint calculated from its exact contents, so if a single byte ever changes the fingerprint stops matching and Git notices. The design decisions Torvalds made in a hurry in 2005 are the ones you rely on every time you use Git now.

The integrity guarantee drives the whole design. Every commit is identified by a hash, a fixed-length fingerprint computed from the commit's full contents, including the ID of its parent. Because the parent's ID feeds into the child's hash, the hashes form a chain: change anything in an old commit and its hash changes, which changes the hash of every commit after it. That is what makes Git history tamper-evident. It also means a commit's ID is a fingerprint of its exact contents, which is why you see those strings of hex like a1b2c3d instead of a tidy commit number 42.

JunoWhere Git came from Linus Torvalds wrote Git in 2005 for the Linux kernel, after the tool the project had been using stopped being free. He built it to be distributed, fast, and safe against corruption. That is why clone gives you the full history to work with offline, and why every commit gets a fingerprint. Handy context for a tool you will use for years.
JunoWhere Git came from Git came out of the Linux kernel in 2005, built for thousands of contributors with no central server, which is why its whole model is distributed. Every clone carries the full history, so you branch and commit locally and sync when you choose. When a Git default feels odd, "it was designed for the kernel" usually explains it.
JunoWhere Git came from Git came out of a two-week sprint by Torvalds in 2005 when the kernel lost access to BitKeeper, with three goals: distributed, fast, integrity-checked. Each commit's hash is computed from its contents plus its parent's hash, so the IDs form a tamper-evident chain. When you wonder why Git made some choice, "it was built for the Linux kernel" is usually the answer.

Where this handbook goes next

With the mental model in place, the rest of the track is about doing the work. Your first repository starts from zero: opening a terminal, installing Git if your machine does not have it, and turning a folder into a repository you can commit to. From there you will learn the everyday loop of saving changes, then branches, merging, and the collaboration flow on GitHub. If a term ever loses you, the Glossary has a short definition for every piece of Git vocabulary in these docs.