GitHub basics
Define the lab goal and success criteria
Github hosts git repositories and adds pull requests, reviews, checks, and permissions around shared branches.
1Try it yourself
Playground
GitHub time machine
Walk commit → branch → recover → PR, with remotes in mind.
1 / 5
- → 1. Make a commit
- ○ 2. Create a branch
- ○ 3. Break a file (oops)
- ○ 4. Recover with checkout / reset
- ○ 5. Open a PR
Commit locally first — remotes come after a clean history.
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.
2Learn the idea
Read
Explain the chapter step
Begin by writing the success condition in observable terms. For this case, success is not familiarity with the vocabulary; it is producing a narrow pull request with a useful summary, reproducible test steps, and a green required check. Record the starting state so you can distinguish an improvement from a result that was already present.
On this page, the practical job is to state a measurable outcome before changing anything. The running case is a branch named improve-evaluation contains one reviewed change that must pass tests before it reaches main.
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
git switch -ccreates and checks out a local feature branch.pytestsupplies evidence before publication; a successful push is not proof that code works.git push -u origin ...sends commits and records the upstream branch.- 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 existsmeans inspectgit remote -vinstead 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
Confirm the Files changed tab contains only the intended files, the base branch is correct, test instructions work from a fresh checkout, and every required check reports success for the latest commit.
For the current explain 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.
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.
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.
Continue learning · glossary & guides
- Which line or command establishes the current step's most important fact?
- What output would reveal that
remote origin already existsmeans inspectgit remote -vinstead of adding a duplicate? - 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?