Chapter DGitHub basicsPage 3 of 8

GitHub basics

Implement the happy path

Github hosts git repositories and adds pull requests, reviews, checks, and permissions around shared branches.

~14 minHappy path

Before you start

Why this matters

Before running anything, predict one observable result from the case: a branch named improve-evaluation contains one reviewed change that must pass tests before it reaches main. Write the prediction beside the command or code line that should cause it. This makes the session an experiment rather than a transcription exercise.

1Learn the idea

Read

Build the chapter step

Build the complete path once without adding optional features. Enter the example exactly, predict the expected output, run it, and compare. Then change one meaningful value connected to a branch named improve-evaluation contains one reviewed change that must pass tests before it reaches main and explain why the result should change.

The deliverable for this step is a narrow pull request with a useful summary, reproducible test steps, and a green required check.

Read

Run the working example

git switch -c improve-evaluation
python -m pytest
git add train.py tests/test_train.py
git commit -m "Test held-out evaluation"
git push -u origin improve-evaluation
git status -sb

Expected evidence:

2 passed in 0.08s
branch 'improve-evaluation' set up to track 'origin/improve-evaluation'.

Read

improve-evaluation...origin/improve-evaluation


The output may include version-specific details such as hashes, paths, fitted thresholds, or final decimal places. Compare the structural facts described here rather than copying placeholders. If the structure differs, stop and inspect the earliest unexpected line.

Read

Read it line by line

  1. git switch -c creates and checks out a local feature branch.
  2. pytest supplies evidence before publication; a successful push is not proof that code works.
  3. git push -u origin ... sends commits and records the upstream branch.
  4. the pull request is created on GitHub after the branch exists; pushing does not merge it.

These lines form one chain: local commits on improve-evaluation plus the repository's pull-request rules becomes a remote feature branch and a reviewable proposal into main. Change only one input first. When several values change together, you cannot tell which change caused the new behavior.

Read

Common errors and fixes

  • First failure: remote origin already exists means inspect git remote -v instead of adding a duplicate. Re-run the smallest command that proves the repair.
  • Second failure: a rejected non-fast-forward push usually means the remote branch moved; fetch and reconcile rather than force-pushing shared history. Preserve the failing input as a test when it represents a realistic mistake.
  • Misleading success: a red required check must be opened and read; rerunning without a code or infrastructure reason hides the actual failure. A clean-looking final line cannot cancel contradictory intermediate evidence.

When debugging, copy the exact error text and inspect names, paths, shapes, types, and versions. Explain the cause in one sentence before changing code. That discipline prevents a guessed repair from creating a second defect.

Read

Evidence for this stage

Merge with the repository's chosen strategy only after review. Then update local main, delete the feature branch when appropriate, and verify the merged commit or squash commit is present.

For the current build step, save the smallest useful evidence: the relevant command, its output, and the input that produced it. Do not use a screenshot as the only record when text can be copied and searched. Keep generated artifacts separate from source inputs so rerunning the example does not destroy the evidence it is meant to evaluate.

Keep the example small enough to inspect manually. Small does not mean careless: boundary values, file locations, feature order, and held-out data still determine whether the result means what you claim.

Read

Reflect on the result

Return to your opening prediction. Mark it correct or rewrite it with the condition you missed. Then explain the difference between a successful execution and a trustworthy result for this specific example.

Checking tutor…

Continue learning · glossary & guides
  1. Which line or command establishes the current step's most important fact?
  2. What output would reveal that a red required check must be opened and read?
  3. Can a new user reproduce a narrow pull request with a useful summary, reproducible test steps, and a green required check from the stated setup?