Git & GitHub

Beginner · Roadmap · 65 lessons · 11 groups

Learn Git from the three areas and your first commit to branching, rebasing, recovering lost work and how Git stores history, then GitHub: pull requests, review, branch protection, and automation with Actions. Sixty-five lessons around one small project.

0%

Not started

Nothing saved yet. Progress is kept in this browser until you sign in.

Start the path

What Git is · 6

Everyday work · 6

Branching and merging · 8

Remotes · 6

Rewriting and recovering · 7

Inside Git · 5

Advanced repositories · 5

Team workflows · 3

GitHub collaboration · 9

The GitHub platform · 3

GitHub Actions · 7

01Why version control existsThe folder-copy problem that made version control necessary, and the three ideas (history, branches, sharing) that a tool like Git adds on top.Beginner · 7 min02Installing and configuring GitInstall Git, set the name, email, editor and default branch it stamps on your work, and learn the three config levels and how to see which one wins.Beginner · 7 min03The three areas of GitWorking directory, staging area and repository: where a change lives at each step, and how to read git status and git diff as a map of those three places.Beginner · 4 min04Your first repository and commitTurn a folder into a Git repository with git init, make two commits for tinynotes, and learn what the hidden .git folder and git status are telling you.Beginner · 5 min05Reading history with log and diffUse git log, git diff and git show to see what changed, when and why, and learn the three comparisons git diff makes: unstaged, staged and between commits.Beginner · 10 min06How Git stores historyGit stores snapshots, not diffs: commits point to trees, trees point to blobs, and every object is named by a hash of its content. See it with git cat-file.Beginner · 15 min01Staging precisely with add -pUse git add -p to stage individual hunks of a file, split a hunk further, and keep each commit about one thing even when your edits were tangled.Beginner · 5 min02Writing good commit messagesWrite commit messages that still make sense in six months: a short imperative subject, a body that explains why, and one idea per commit.Beginner · 11 min03Ignoring files with .gitignoreKeep generated files, secrets and local data out of Git with .gitignore: how patterns match, how to check them, and why a tracked file ignores your ignore rule.Beginner · 6 min04Undoing uncommitted changesUse git restore to discard edits and unstage files, and git clean to remove untracked files, plus which of these can never be taken back.Beginner · 13 min05Amending the last commitFix a typo in the last commit message or fold in a forgotten change with git commit --amend, and understand why it replaces the commit instead of editing it.Beginner · 3 min06Renaming, moving and deleting filesUse git mv and git rm to rename, move and delete tracked files, and learn that Git detects renames by comparing content rather than recording them.Beginner · 4 min01What a branch isA Git branch is a 41-byte file holding one commit ID. See branches, HEAD and the commit graph in .git, and learn why creating and switching branches is instant.Beginner · 4 min02Creating and switching branchesCreate, switch, rename and delete branches with git switch and git branch, and see what Git does with uncommitted changes when you switch.Beginner · 6 min03Merging: fast-forward and three-wayCombine branches with git merge, and see why Git sometimes just moves a pointer (fast-forward) and sometimes builds a two-parent merge commit (three-way).Beginner · 9 min04Resolving merge conflictsRead conflict markers, choose or combine the two sides, and finish or abort a merge, including the mistake of committing the markers themselves.Beginner · 5 min05Rebasing a branchReplay a branch's commits on top of another branch with git rebase, see why their IDs change, and handle a conflict mid-rebase with continue, skip or abort.Intermediate · 10 min06Merge or rebase: choosingCompare merge and rebase on the same branch, see the two history shapes, and learn the one rule that decides which to use: has anyone else got these commits?Intermediate · 5 min07Stashing unfinished workShelve uncommitted changes with git stash, bring them back with pop or apply, include untracked files, and use --keep-index to test only what you staged.Intermediate · 5 min08Cherry-picking commitsCopy a single commit onto another branch with git cherry-pick, see why the copy gets a new ID, and handle conflicts, ranges, merge commits and duplicates.Intermediate · 15 min01Remotes, clone and originA remote is just a named URL for another copy of your repository. Learn what origin really is, what clone sets up, and how to add a remote by hand.Beginner · 7 min02Fetch, pull and pushMove commits between your repository and a remote: fetch to look, pull to integrate, push to publish, and what to do when a push is rejected.Beginner · 7 min03Upstream tracking branchesHow a local branch is linked to a remote branch, what git push -u really writes, and how to read ahead, behind and gone in git status.Intermediate · 16 min04Force pushing safelyWhy a rewritten branch needs a force push, why --force-with-lease beats --force, and the one case where even the lease lets you overwrite a teammate.Intermediate · 9 min05Tags and releasesMark a commit as version 1.0 with a tag. Lightweight versus annotated tags, why git push doesn't send them, and what to do about a tag you got wrong.Intermediate · 11 min06Forks and multiple remotesContribute to a repo you can't push to: sync your fork through an upstream remote, branch from it, and set push defaults so you never push to the wrong place.Intermediate · 3 min01Interactive rebaseRewrite a branch before sharing it: squash noise commits, fix a message, drop a mistake, and use fixup commits with autosquash, all via the rebase todo list.Intermediate · 8 min02Reset, soft, mixed and hardMove a branch back to an earlier commit and decide what happens to the index and your files: the three modes of git reset, tested on a real repository.Intermediate · 10 min03Reverting a commitUndo a commit that is already published by adding a new commit that reverses it, including the extra step needed for merge commits and how to reapply one.Intermediate · 9 min04The reflog and recovering lost workUse the reflog to find commits that no branch points to any more: undo a hard reset, bring back a deleted branch, and learn when Git really does delete them.Intermediate · 14 min05Finding a bug with bisectBinary-search your history to find the commit that introduced a bug, first by hand and then automatically with git bisect run and a test script.Intermediate · 17 min06Blame and searching historyFind who last changed a line and why with git blame, ignore reformatting commits, and search history for when a string appeared with git log -S, -G and -L.Intermediate · 6 min07Removing secrets from historyA committed secret stays in history after you delete the file. Rotate it first, then rewrite history, force push and clean up, with a real filter-branch run.Intermediate · 11 min01Objects, blobs, trees and commitsBuild a commit by hand with plumbing commands to see that Git is a content-addressed store of four object types, and why identical content is only stored once.Intermediate · 9 min02Refs, branches and HEADA branch is a 41-byte file. Look at .git/refs, HEAD as a symbolic ref, detached HEAD, packed-refs, and the reflog files, using only cat and find.Intermediate · 8 min03Packfiles, garbage collection and repo sizeWatch loose objects become a delta-compressed packfile with git gc, find what makes a repo big, and see why deleting a large file doesn't shrink history.Intermediate · 5 min04Git hooksRun your own scripts at key moments in Git: write pre-commit, commit-msg and pre-push hooks, share them via core.hooksPath, and why hooks aren't security.Intermediate · 6 min05Configuration, aliases and attributesLearn Git's layered config files, write aliases for common commands, switch identity by directory with includeIf, and use .gitattributes for line endings.Intermediate · 12 min01WorktreesCheck out several branches of one repository at once in separate folders with git worktree, no stashing or recloning, and learn to remove them cleanly.Intermediate · 6 min02Submodules and subtreesInclude one repository inside another at a pinned commit with submodules, or copy it in with subtree. See how each is stored, what a clone gets, and the traps.Intermediate · 8 min03Large files and Git LFSWhy big binary files bloat a repository forever, how Git LFS swaps them for pointer files using clean and smudge filters, and what I could and could not run.Intermediate · 8 min04Partial clones and sparse checkoutWork in a huge repository without downloading all of it: blobless partial clones, sparse checkout of one folder, shallow clones, and the trade-offs of each.Advanced · 10 min05Signing commits and tagsProve who made a commit or tag by signing it with an SSH key, set up allowed signers, read the G, U and N statuses, and see what rewriting does to signatures.Intermediate · 9 min01Trunk-based developmentKeep one main branch that is always releasable, merge small changes into it every day, and hide unfinished work behind a flag instead of a long-lived branch.Intermediate · 14 min02Feature branches and GitflowCompare the three common branching models, feature branches, GitHub flow and Gitflow, and pick the lightest one that fits how you release.Intermediate · 32 min03Conventional Commits and semantic versioningWrite commit messages in a fixed shape so a tool can read them, and use them to decide the next version number: patch, minor or major.Intermediate · 15 min01GitHub accounts, SSH keys and authenticationProve who you are to GitHub from the command line: generate an ed25519 SSH key, add the public half to your account, and know when HTTPS tokens fit better.Beginner · 6 min02Creating and publishing a repositoryTurn a local Git project into a GitHub repository: create an empty remote, connect it with git remote add, push main, and choose visibility, license and README.Beginner · 10 min03Pull requestsA pull request asks to merge one branch into another and gives the team a place to review and test first. Learn what it contains and how to write one.Beginner · 4 min04Code review on GitHubReview a pull request line by line: batch comments, propose exact edits with suggestions, choose Comment, Approve or Request changes, and respond well.Beginner · 10 min05Merge methods: squash, rebase and mergeGitHub offers three ways to merge a pull request. See the history each leaves, why a squashed branch looks unmerged to Git, and which suits your team.Intermediate · 6 min06Issues and projectsTrack bugs, ideas and tasks as GitHub issues, link them to pull requests so merging closes them, and plan the work on a Projects board or table.Beginner · 8 min07Branch protection and rulesetsTurn 'main must stay green' into a rule GitHub enforces: require pull requests, reviews and passing checks, and block force pushes and deletion.Intermediate · 15 min08CODEOWNERS and templatesRoute reviews to the right people with a CODEOWNERS file, and give contributors issue forms and a pull request template so reports arrive with what you need.Intermediate · 25 min09The GitHub CLIUse gh to create repositories, open and merge pull requests, file issues and watch Actions runs from the terminal, and call any GitHub API endpoint with gh api.Intermediate · 42 min01GitHub PagesPublish a static site from a repository: choose a branch or a GitHub Actions workflow as the source, know the limits, and keep unwanted files out.Beginner · 24 min02Dependabot and dependency updatesKeep dependencies and Actions current with Dependabot: alerts, security and version updates, a working dependabot.yml, and reviewing its pull requests.Intermediate · 28 min03Secret scanning and code securityWhy a pushed secret is a leaked secret, how secret scanning and push protection catch it, and where CodeQL and dependency review fit.Intermediate · 3 min01Workflows, triggers, jobs and stepsWrite your first GitHub Actions workflow: a YAML file that runs the tests when you push or open a pull request, built from triggers, jobs and steps.Beginner · 8 min02Runners and the marketplaceChoose where a workflow runs, GitHub-hosted or self-hosted, and learn how marketplace actions are versioned, found and trusted before you use them.Intermediate · 20 min03Secrets, variables and contextsGive a workflow credentials and settings safely: secrets, variables, the GITHUB_TOKEN, and the contexts behind every ${{ }} expression.Intermediate · 23 min04Caching, artifacts and matrix buildsSpeed up CI by caching dependencies, pass build output between jobs as artifacts, and test several Node versions with a matrix, avoiding name clashes.Intermediate · 16 min05Reusable workflows and composite actionsStop copying the same YAML between repositories: share whole jobs with reusable workflows, share a few steps with composite actions, and know which one to pick.Intermediate · 5 min06Deploying from Actions with OIDCDeploy to a cloud account without a long-lived key in GitHub: let each workflow run prove its identity with OpenID Connect and get a short-lived credential.Advanced · 17 min07Hardening your workflowsMake a workflow a hard target: least-privilege tokens, SHA-pinned actions, no script injection from pull request text, and care with privileged triggers.Advanced · 17 min

What Git is

6 lessons

  1. 01 / 06Why version control existsThe folder-copy problem that made version control necessary, and the three ideas (history, branches, sharing) that a tool like Git adds on top.7 min
  2. 02 / 06Installing and configuring GitInstall Git, set the name, email, editor and default branch it stamps on your work, and learn the three config levels and how to see which one wins.7 min
  3. 03 / 06The three areas of GitWorking directory, staging area and repository: where a change lives at each step, and how to read git status and git diff as a map of those three places.4 min
  4. 04 / 06Your first repository and commitTurn a folder into a Git repository with git init, make two commits for tinynotes, and learn what the hidden .git folder and git status are telling you.5 min
  5. 05 / 06Reading history with log and diffUse git log, git diff and git show to see what changed, when and why, and learn the three comparisons git diff makes: unstaged, staged and between commits.10 min
  6. 06 / 06How Git stores historyGit stores snapshots, not diffs: commits point to trees, trees point to blobs, and every object is named by a hash of its content. See it with git cat-file.15 min

Everyday work

6 lessons

  1. 01 / 06Staging precisely with add -pUse git add -p to stage individual hunks of a file, split a hunk further, and keep each commit about one thing even when your edits were tangled.5 min
  2. 02 / 06Writing good commit messagesWrite commit messages that still make sense in six months: a short imperative subject, a body that explains why, and one idea per commit.11 min
  3. 03 / 06Ignoring files with .gitignoreKeep generated files, secrets and local data out of Git with .gitignore: how patterns match, how to check them, and why a tracked file ignores your ignore rule.6 min
  4. 04 / 06Undoing uncommitted changesUse git restore to discard edits and unstage files, and git clean to remove untracked files, plus which of these can never be taken back.13 min
  5. 05 / 06Amending the last commitFix a typo in the last commit message or fold in a forgotten change with git commit --amend, and understand why it replaces the commit instead of editing it.3 min
  6. 06 / 06Renaming, moving and deleting filesUse git mv and git rm to rename, move and delete tracked files, and learn that Git detects renames by comparing content rather than recording them.4 min

Branching and merging

8 lessons

  1. 01 / 08What a branch isA Git branch is a 41-byte file holding one commit ID. See branches, HEAD and the commit graph in .git, and learn why creating and switching branches is instant.4 min
  2. 02 / 08Creating and switching branchesCreate, switch, rename and delete branches with git switch and git branch, and see what Git does with uncommitted changes when you switch.6 min
  3. 03 / 08Merging: fast-forward and three-wayCombine branches with git merge, and see why Git sometimes just moves a pointer (fast-forward) and sometimes builds a two-parent merge commit (three-way).9 min
  4. 04 / 08Resolving merge conflictsRead conflict markers, choose or combine the two sides, and finish or abort a merge, including the mistake of committing the markers themselves.5 min
  5. 05 / 08Rebasing a branchReplay a branch's commits on top of another branch with git rebase, see why their IDs change, and handle a conflict mid-rebase with continue, skip or abort.10 min
  6. 06 / 08Merge or rebase: choosingCompare merge and rebase on the same branch, see the two history shapes, and learn the one rule that decides which to use: has anyone else got these commits?5 min
  7. 07 / 08Stashing unfinished workShelve uncommitted changes with git stash, bring them back with pop or apply, include untracked files, and use --keep-index to test only what you staged.5 min
  8. 08 / 08Cherry-picking commitsCopy a single commit onto another branch with git cherry-pick, see why the copy gets a new ID, and handle conflicts, ranges, merge commits and duplicates.15 min

Remotes

6 lessons

  1. 01 / 06Remotes, clone and originA remote is just a named URL for another copy of your repository. Learn what origin really is, what clone sets up, and how to add a remote by hand.7 min
  2. 02 / 06Fetch, pull and pushMove commits between your repository and a remote: fetch to look, pull to integrate, push to publish, and what to do when a push is rejected.7 min
  3. 03 / 06Upstream tracking branchesHow a local branch is linked to a remote branch, what git push -u really writes, and how to read ahead, behind and gone in git status.16 min
  4. 04 / 06Force pushing safelyWhy a rewritten branch needs a force push, why --force-with-lease beats --force, and the one case where even the lease lets you overwrite a teammate.9 min
  5. 05 / 06Tags and releasesMark a commit as version 1.0 with a tag. Lightweight versus annotated tags, why git push doesn't send them, and what to do about a tag you got wrong.11 min
  6. 06 / 06Forks and multiple remotesContribute to a repo you can't push to: sync your fork through an upstream remote, branch from it, and set push defaults so you never push to the wrong place.3 min

Rewriting and recovering

7 lessons

  1. 01 / 07Interactive rebaseRewrite a branch before sharing it: squash noise commits, fix a message, drop a mistake, and use fixup commits with autosquash, all via the rebase todo list.8 min
  2. 02 / 07Reset, soft, mixed and hardMove a branch back to an earlier commit and decide what happens to the index and your files: the three modes of git reset, tested on a real repository.10 min
  3. 03 / 07Reverting a commitUndo a commit that is already published by adding a new commit that reverses it, including the extra step needed for merge commits and how to reapply one.9 min
  4. 04 / 07The reflog and recovering lost workUse the reflog to find commits that no branch points to any more: undo a hard reset, bring back a deleted branch, and learn when Git really does delete them.14 min
  5. 05 / 07Finding a bug with bisectBinary-search your history to find the commit that introduced a bug, first by hand and then automatically with git bisect run and a test script.17 min
  6. 06 / 07Blame and searching historyFind who last changed a line and why with git blame, ignore reformatting commits, and search history for when a string appeared with git log -S, -G and -L.6 min
  7. 07 / 07Removing secrets from historyA committed secret stays in history after you delete the file. Rotate it first, then rewrite history, force push and clean up, with a real filter-branch run.11 min

Inside Git

5 lessons

  1. 01 / 05Objects, blobs, trees and commitsBuild a commit by hand with plumbing commands to see that Git is a content-addressed store of four object types, and why identical content is only stored once.9 min
  2. 02 / 05Refs, branches and HEADA branch is a 41-byte file. Look at .git/refs, HEAD as a symbolic ref, detached HEAD, packed-refs, and the reflog files, using only cat and find.8 min
  3. 03 / 05Packfiles, garbage collection and repo sizeWatch loose objects become a delta-compressed packfile with git gc, find what makes a repo big, and see why deleting a large file doesn't shrink history.5 min
  4. 04 / 05Git hooksRun your own scripts at key moments in Git: write pre-commit, commit-msg and pre-push hooks, share them via core.hooksPath, and why hooks aren't security.6 min
  5. 05 / 05Configuration, aliases and attributesLearn Git's layered config files, write aliases for common commands, switch identity by directory with includeIf, and use .gitattributes for line endings.12 min

Advanced repositories

5 lessons

  1. 01 / 05WorktreesCheck out several branches of one repository at once in separate folders with git worktree, no stashing or recloning, and learn to remove them cleanly.6 min
  2. 02 / 05Submodules and subtreesInclude one repository inside another at a pinned commit with submodules, or copy it in with subtree. See how each is stored, what a clone gets, and the traps.8 min
  3. 03 / 05Large files and Git LFSWhy big binary files bloat a repository forever, how Git LFS swaps them for pointer files using clean and smudge filters, and what I could and could not run.8 min
  4. 04 / 05Partial clones and sparse checkoutWork in a huge repository without downloading all of it: blobless partial clones, sparse checkout of one folder, shallow clones, and the trade-offs of each.10 min
  5. 05 / 05Signing commits and tagsProve who made a commit or tag by signing it with an SSH key, set up allowed signers, read the G, U and N statuses, and see what rewriting does to signatures.9 min

Team workflows

3 lessons

  1. 01 / 03Trunk-based developmentKeep one main branch that is always releasable, merge small changes into it every day, and hide unfinished work behind a flag instead of a long-lived branch.14 min
  2. 02 / 03Feature branches and GitflowCompare the three common branching models, feature branches, GitHub flow and Gitflow, and pick the lightest one that fits how you release.32 min
  3. 03 / 03Conventional Commits and semantic versioningWrite commit messages in a fixed shape so a tool can read them, and use them to decide the next version number: patch, minor or major.15 min

GitHub collaboration

9 lessons

  1. 01 / 09GitHub accounts, SSH keys and authenticationProve who you are to GitHub from the command line: generate an ed25519 SSH key, add the public half to your account, and know when HTTPS tokens fit better.6 min
  2. 02 / 09Creating and publishing a repositoryTurn a local Git project into a GitHub repository: create an empty remote, connect it with git remote add, push main, and choose visibility, license and README.10 min
  3. 03 / 09Pull requestsA pull request asks to merge one branch into another and gives the team a place to review and test first. Learn what it contains and how to write one.4 min
  4. 04 / 09Code review on GitHubReview a pull request line by line: batch comments, propose exact edits with suggestions, choose Comment, Approve or Request changes, and respond well.10 min
  5. 05 / 09Merge methods: squash, rebase and mergeGitHub offers three ways to merge a pull request. See the history each leaves, why a squashed branch looks unmerged to Git, and which suits your team.6 min
  6. 06 / 09Issues and projectsTrack bugs, ideas and tasks as GitHub issues, link them to pull requests so merging closes them, and plan the work on a Projects board or table.8 min
  7. 07 / 09Branch protection and rulesetsTurn 'main must stay green' into a rule GitHub enforces: require pull requests, reviews and passing checks, and block force pushes and deletion.15 min
  8. 08 / 09CODEOWNERS and templatesRoute reviews to the right people with a CODEOWNERS file, and give contributors issue forms and a pull request template so reports arrive with what you need.25 min
  9. 09 / 09The GitHub CLIUse gh to create repositories, open and merge pull requests, file issues and watch Actions runs from the terminal, and call any GitHub API endpoint with gh api.42 min

The GitHub platform

3 lessons

  1. 01 / 03GitHub PagesPublish a static site from a repository: choose a branch or a GitHub Actions workflow as the source, know the limits, and keep unwanted files out.24 min
  2. 02 / 03Dependabot and dependency updatesKeep dependencies and Actions current with Dependabot: alerts, security and version updates, a working dependabot.yml, and reviewing its pull requests.28 min
  3. 03 / 03Secret scanning and code securityWhy a pushed secret is a leaked secret, how secret scanning and push protection catch it, and where CodeQL and dependency review fit.3 min

GitHub Actions

7 lessons

  1. 01 / 07Workflows, triggers, jobs and stepsWrite your first GitHub Actions workflow: a YAML file that runs the tests when you push or open a pull request, built from triggers, jobs and steps.8 min
  2. 02 / 07Runners and the marketplaceChoose where a workflow runs, GitHub-hosted or self-hosted, and learn how marketplace actions are versioned, found and trusted before you use them.20 min
  3. 03 / 07Secrets, variables and contextsGive a workflow credentials and settings safely: secrets, variables, the GITHUB_TOKEN, and the contexts behind every ${{ }} expression.23 min
  4. 04 / 07Caching, artifacts and matrix buildsSpeed up CI by caching dependencies, pass build output between jobs as artifacts, and test several Node versions with a matrix, avoiding name clashes.16 min
  5. 05 / 07Reusable workflows and composite actionsStop copying the same YAML between repositories: share whole jobs with reusable workflows, share a few steps with composite actions, and know which one to pick.5 min
  6. 06 / 07Deploying from Actions with OIDCDeploy to a cloud account without a long-lived key in GitHub: let each workflow run prove its identity with OpenID Connect and get a short-lived credential.17 min
  7. 07 / 07Hardening your workflowsMake a workflow a hard target: least-privilege tokens, SHA-pinned actions, no script injection from pull request text, and care with privileged triggers.17 min
Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark