{"id":"l-git-1-1","courseId":"git-github","lang":"en","kind":"intro","summary":"Explain what problem version control solves, how Git’s snapshot model differs from saving copies of files, and how Git and GitHub split the work.","html":"<p>Every developer has a folder somewhere with <code dir=\"ltr\">index.html</code>, <code dir=\"ltr\">index-old.html</code>, <code dir=\"ltr\">index-final.html</code> and <code dir=\"ltr\">index-final-REAL.html</code>. It works until the day you need to know which version had the working menu, what you changed between Tuesday and Thursday, or how to combine your fix with a friend’s edits from the same morning. Copies of files can’t answer any of that.</p>\n<p>Version control is the tool for those questions. It keeps a history of your project as a series of saved states, each with a date, an author and a note explaining why. You can compare any two states, return to an old one, try an idea on the side and throw it away, and share the whole history with other people. Git is the version control system almost every team uses in 2026, and GitHub is where most of those teams keep their shared copy.</p>\n<h2 id=\"sec-1\" tabindex=\"-1\">Snapshots, not edits</h2>\n<p>Git’s core idea is small. When you commit, Git records a <strong>snapshot</strong>: the full contents of every file it tracks, at that moment. Files that didn’t change aren’t stored twice; Git reuses what it already has. Each commit also stores a pointer to the commit that came before it, its <strong>parent</strong>. Follow those pointers backwards and you have the project’s history.</p>\n<figure class=\"diagram\"><svg class=\"diagram-svg\" focusable=\"false\" viewBox=\"0 0 700 250\" role=\"img\" aria-labelledby=\"l-git-1-1-t1\"><defs><marker id=\"arrow-l-git-1-1-1\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0 L10 5 L0 10 z\" class=\"d-arrowhead\"/></marker></defs>\n  <title id=\"l-git-1-1-t1\">Left: three loose copies of index.html with no link between them. Right: three commits, each a snapshot of the whole project, each pointing back to its parent, with a message on every commit.</title>\n  <text class=\"d-label-strong\" x=\"30\" y=\"30\">Copies</text>\n  <rect class=\"d-box-warn\" x=\"30\" y=\"50\" width=\"200\" height=\"40\" rx=\"8\"/>\n  <text class=\"d-code\" x=\"45\" y=\"76\">index.html</text>\n  <rect class=\"d-box-warn\" x=\"30\" y=\"105\" width=\"200\" height=\"40\" rx=\"8\"/>\n  <text class=\"d-code\" x=\"45\" y=\"131\">index-final.html</text>\n  <rect class=\"d-box-warn\" x=\"30\" y=\"160\" width=\"200\" height=\"40\" rx=\"8\"/>\n  <text class=\"d-code\" x=\"45\" y=\"186\">index-final-REAL.html</text>\n  <text class=\"d-label-muted\" x=\"30\" y=\"230\">Which is newest? What changed?</text>\n  <text class=\"d-label-strong\" x=\"290\" y=\"30\">Commits</text>\n  <rect class=\"d-box-primary\" x=\"290\" y=\"60\" width=\"120\" height=\"110\" rx=\"10\"/>\n  <text class=\"d-label-strong\" x=\"305\" y=\"85\">a1f3</text>\n  <text class=\"d-code\" x=\"305\" y=\"110\">index.html</text>\n  <text class=\"d-code\" x=\"305\" y=\"130\">styles.css</text>\n  <text class=\"d-label-muted\" x=\"305\" y=\"155\">\"Add home\"</text>\n  <rect class=\"d-box-primary\" x=\"440\" y=\"60\" width=\"120\" height=\"110\" rx=\"10\"/>\n  <text class=\"d-label-strong\" x=\"455\" y=\"85\">7c2e</text>\n  <text class=\"d-code\" x=\"455\" y=\"110\">index.html</text>\n  <text class=\"d-code\" x=\"455\" y=\"130\">styles.css</text>\n  <text class=\"d-label-muted\" x=\"455\" y=\"155\">\"Add menu\"</text>\n  <rect class=\"d-box-primary\" x=\"590\" y=\"60\" width=\"100\" height=\"110\" rx=\"10\"/>\n  <text class=\"d-label-strong\" x=\"605\" y=\"85\">d90b</text>\n  <text class=\"d-code\" x=\"605\" y=\"110\">index.html</text>\n  <text class=\"d-code\" x=\"605\" y=\"130\">styles.css</text>\n  <text class=\"d-label-muted\" x=\"605\" y=\"155\">\"Fix nav\"</text>\n  <path class=\"d-arrow\" d=\"M440 115 L414 115\" marker-end=\"url(#arrow-l-git-1-1-1)\"/>\n  <path class=\"d-arrow\" d=\"M590 115 L564 115\" marker-end=\"url(#arrow-l-git-1-1-1)\"/>\n  <text class=\"d-label-muted\" x=\"290\" y=\"205\">Each commit points back to its parent.</text>\n</svg><figcaption>Copies of files versus a chain of commits</figcaption></figure>\n<p>Notice the arrows point backwards. A commit knows its parent, never its children, because the children didn’t exist when it was made. That one detail explains a lot of Git’s behaviour later, including why you can’t “edit” an old commit, only replace it with a new one.</p>\n<h2 id=\"sec-2\" tabindex=\"-1\">Git versus GitHub</h2>\n<p>People use the two names as if they were one thing. They aren’t.</p>\n<ul>\n<li><strong>Git</strong> is a program on your computer. The whole history lives in a hidden <code dir=\"ltr\">.git</code> folder inside your project. Committing, branching, merging and reading history all happen locally and work on a plane.</li>\n<li><strong>GitHub</strong> is a website and service that hosts Git repositories. It adds what a team needs around Git: a shared copy everyone pushes to, pull requests for code review, issues, project boards, and GitHub Actions for automated checks.</li>\n</ul>\n<p>You can use Git without GitHub (plenty of teams use GitLab or Bitbucket), but GitHub without Git makes no sense. This course teaches Git first, then GitHub on top of it.</p>\n<aside class=\"callout callout-why\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><circle cx=\"12\" cy=\"12\" r=\"6\"/><circle cx=\"12\" cy=\"12\" r=\"2\"/></svg><span><span class=\"callout-kind\">Why this matters</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Why Git feels hard, and how this course fixes it</span></p>\n<p>Most people learn Git as a list of commands to memorize, so every unexpected message feels like a disaster. Git’s commands are moves on a small graph of commits and labels. Once you can picture that graph, a command stops being a gamble and becomes a prediction you can check with <code dir=\"ltr\">git log --graph</code>. Expect a lot of diagrams.</p>\n</aside>\n<h2 id=\"sec-3\" tabindex=\"-1\">What you’ll build</h2>\n<p>You’ll work on one project all course: your own portfolio site, a repository called <code dir=\"ltr\">portfolio</code> with an <code dir=\"ltr\">index.html</code>, a <code dir=\"ltr\">styles.css</code>, a projects page and a tiny <code dir=\"ltr\">npm test</code> script that checks the HTML. In section 1 you turn the folder into a repository and learn to read its history. In section 2 you branch, merge, rebase and fix a real conflict. In section 3 you put it on GitHub and work through pull requests. In section 4 you learn to undo mistakes safely and finish with a protected <code dir=\"ltr\">main</code> branch where GitHub Actions checks every pull request before it can merge.</p>\n<p>Next, you install Git, tell it who you are, and make your first commit.</p>\n","toc":[{"id":"sec-1","text":"Snapshots, not edits","level":2},{"id":"sec-2","text":"Git versus GitHub","level":2},{"id":"sec-3","text":"What you’ll build","level":2}],"takeaways":["Version control records named, dated snapshots of a whole project so you can compare, undo and share changes safely.","A Git commit is a snapshot of every tracked file plus a pointer to the commit before it, not a list of edits.","Git runs on your machine and works offline; GitHub is a hosting service built around Git repositories.","Most Git confusion disappears once you can draw the commit graph and say where your branch and HEAD point."],"further":[{"title":"Pro Git, Getting Started - What is Git?","url":"https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F"},{"title":"About Git (GitHub Docs)","url":"https://docs.github.com/en/get-started/using-git/about-git"}],"quiz":[{"q":"<p>You save <code dir=\"ltr\">index.html</code>, <code dir=\"ltr\">index-v2.html</code> and <code dir=\"ltr\">index-final.html</code> in one folder. Which problem does Git solve that this habit doesn’t?</p>","options":[{"text":"Git makes the files smaller, so the folder uses less disk space.","why":"Git does compress what it stores, but saving space isn’t the problem here. The problem is knowing what changed, when, why, and across which files."},{"text":"Git records the whole project at each point, with a message and a date, so you can compare or return to any version.","why":"Correct. A commit captures every tracked file together, with who, when and why, which loose copies of one file can’t do."},{"text":"Git stops you from editing files that already have a saved version.","why":"Git never locks files. You edit freely; Git only records what you choose to commit."},{"text":"Git uploads each version to the cloud automatically.","why":"Git is entirely local until you push. Uploading is a separate, deliberate step that involves a remote such as GitHub."}],"answer":1},{"q":"<p>What does a single Git commit contain?</p>","options":[{"text":"Only the lines that changed since the previous commit.","why":"That describes a diff. Git shows you diffs, but it computes them by comparing two snapshots; the commit itself records the full state."},{"text":"A copy of the files you staged, and nothing about earlier commits.","why":"A commit always points to its parent commit (or parents). That link is what turns separate snapshots into a history."},{"text":"A snapshot of all tracked files, the author, a message, and a pointer to its parent commit.","why":"Correct. Snapshot plus parent pointer is the whole model; history, branches and merges all fall out of it."}],"answer":2},{"q":"<p>Your train has no Wi-Fi. Which of these can you still do?</p>","options":[{"text":"Commit, view history, create branches and merge them.","why":"Correct. The full repository lives in the <code dir=\"ltr\">.git</code> folder on your machine, so everything except talking to a remote works offline."},{"text":"Nothing; Git needs to reach GitHub for every command.","why":"Git was designed to be distributed. Only commands that talk to a remote, such as push, fetch, pull and clone, need a network connection."},{"text":"Only <code dir=\"ltr\">git status</code>, because commits are created on GitHub’s servers.","why":"Commits are created locally by <code dir=\"ltr\">git commit</code>. GitHub only receives them later when you push."}],"answer":0}],"exercise":null,"words":568,"readMinutes":3}