Week 1: How Git really works
What Git and GitHub each do, how one change travels from your editor to GitHub, and a laptop set up the way your team expects.
Today you will
- Explain the difference between Git and GitHub, and where VS Code and GitHub Desktop fit in.
- Follow one change from your editor to GitHub: edit,
git add, git commit, git push. - Find any Git setting, and the file it comes from, with
git config --list --show-origin. - Set up Git, VS Code and GitHub Desktop the way your team expects, and pass the lab doctor.
Working folder, staging area and repository: commit exactly what you mean to, and keep secrets and data out with .gitignore.
Today you will
- Name Git's three areas and the command that moves work between them.
- Read
git status and say what each section means. - Stage and commit exactly the files you mean to, and unstage the ones you don't.
- Keep secrets and data out of Git with
.gitignore and git rm --cached. - Write a short commit message that says what the commit does.
Commits, parents and HEAD. Read history like a detective, write messages your team will thank you for, and fix your last commit.
Today you will
- Explain what a commit stores, and how parents link commits into a graph.
- Read history with
git log, the git lg alias (one of the Day 1 course settings), git show and git diff. - Find which commit added a piece of text, and who last changed a line.
- Write a clear commit message, and fix your last commit with
git commit --amend.
Branches are movable labels. Switch safely, shelve half-done work, and escape detached HEAD.
Today you will
- Explain what a branch and
HEAD really are: labels, not copies of your files. - Create, switch and delete branches with
git switch and git branch, and recognise the older git checkout. - Predict when uncommitted changes follow you to another branch, and when Git refuses to switch.
- Shelve unfinished work with
git stash, and rescue a commit made in detached HEAD.
Bring two lines of work together, and resolve a conflict calmly when Git needs your judgement.
Today you will
- Tell a fast-forward from a merge commit, and predict which one you'll get.
- Read conflict markers and know which side is which.
- Resolve a conflict in the VS Code merge editor, then finish the merge.
- Back out of a merge you're not ready for with
git merge --abort.
origin, origin/main, ahead and behind, and what to do when your push is rejected.
Today you will
- Explain what a remote is, what
origin is, and what origin/main really tracks. - Clone a repository, and read ahead, behind and diverged in
git status. - Choose between
git fetch, git pull and git push, and publish a new branch with git push -u. - Fix a rejected push with a merge (
git pull --no-rebase) or a rebase (git pull --rebase), never with --force.
Sign in from Git, create repos the right way, publish your journal, and clone the team sandbox like on day one at work.
Today you will
- Push to GitHub over HTTPS (browser sign-in) or SSH, and tell the two URLs apart.
- Connect a local repo to an empty GitHub repo with
git remote add and git push -u. - Recognise refusing to merge unrelated histories and fix it.
- Publish your journal, push the team sandbox, and clone it with GitHub Desktop.
- Find your way around a repository page on github.com.
Week 2: Working in a team
Branch, push, open a pull request, pass the checks, squash-merge, and tidy up afterwards.
Today you will
- Explain what a pull request is and why teams change
main only through them. - Push a branch and open a pull request with a description reviewers can act on.
- Pick one of the three merge buttons and predict what lands on
main. - Sync and tidy up after a merge, including why
git branch -d refuses after a squash. - Undo a merged pull request safely with Revert.
Issues that close themselves, a red check turned green, and reviews with suggested changes.
Today you will
- Log a bug as an issue and link your pull request to it, so the issue closes itself on merge.
- Read a failing check's log and turn it green with a new commit.
- Review a pull request on Files changed with labelled comments, a suggested change and the right verdict.
- Receive review calmly, and
git pull commits made on GitHub before you push again. - Explain what protected branches, rulesets and CODEOWNERS enforce.
Work on a teammate's branch, keep your own branch current, and force-push without erasing anyone's work.
Today you will
- Work on a teammate's branch, and fix a rejected push with
git pull --rebase. - Choose between merging
main into your branch and rebasing onto it, and know when not to rebase. - Force-push a rebased branch with
--force-with-lease, and know what (stale info) means. - Continue, skip or abort a rebase that stops on a conflict.
- Explain what your
pull.rebase true setting does (you turned it on on Day 1), check it, and know when a team chooses differently.
Fix any mistake calmly: ask whether it's pushed, then pick the right undo, from reset and revert to the reflog.
Today you will
- Pick the right undo by asking one question first: did you push it?
- Move a branch back with
git reset --soft, --mixed or --hard, and know what each one keeps. - Undo a pushed commit safely with
git revert, including a merge with -m 1. - Find "lost" commits with
git reflog and bring them back. - Move commits to the right branch, copy one with
git cherry-pick, and clear junk with git clean.
Notebooks, secrets, data files and big files: keep Git for your code, and keep everything else out cleanly.
Today you will
- Sort a data project's files into goes in Git and stays out, and check your
.gitignore rules. - Commit notebooks without outputs, and get out of a notebook conflict calmly.
- Stop tracking a committed file with
git rm --cached while keeping it on disk. - Recover from GitHub's GH001 big-file rejection, and know what Git LFS is for.
- Explain why a file can look "completely changed", and fix it for the team with
.gitattributes.
Mark releases with tags, publish them on GitHub, ship a hotfix from a tag, and learn how different teams branch.
Today you will
- Create an annotated tag with a semantic version number, and push it.
- Publish a GitHub Release from a tag, with generated release notes.
- Ship a hotfix from a release tag, then cherry-pick it back into
main. - Compare GitHub Flow, Git Flow and trunk-based development, and know what to ask your team.
One realistic workday with Alex and Sam, from the morning sync to a hotfix release and a clean desk at 17:30.
Today you will
- Run a whole team workday on your own: sync, branch, small commits, push, pull request, clean-up.
- Rebase onto a teammate's merged work, resolve the conflict and push with
--force-with-lease. - Ship a hotfix from a release tag while your own unfinished work waits in the stash.
- End the day with a clean
git status and nothing unpushed.
Bonus: Pro skills
Squash, reword and reorder your own commits before anyone reviews them.
Today you will
- Open the todo list with
git rebase -i main and use pick, reword, squash, fixup and drop. - Reorder commits by moving lines.
- Fix an older commit later with
git commit --fixup and --autosquash. - Know when rewriting is allowed, push with
--force-with-lease, and escape with git rebase --abort.
Binary-search your history to find exactly which commit broke the tests.
Today you will
- Explain how bisect halves the list of suspect commits at every step.
- Start a session with
git bisect start, git bisect bad and git bisect good v1.0.0. - Let Git test every step with
git bisect run python -m unittest, or answer good and bad yourself. - Finish cleanly with
git bisect reset.
Contribute to a repo you can't push to, and keep your fork in sync.
Today you will
- Explain the fork triangle: upstream, your fork (origin) and your clone.
- Add an
upstream remote and fetch it. - Sync your fork:
git merge --ff-only upstream/main, then git push origin main. - Open a pull request from a branch on your fork to the original repository.
Let Git check your work before it leaves your laptop, and work on two branches at once.
Today you will
- Explain what a pre-commit hook is and write a small one.
- Read a team's
.pre-commit-config.yaml and know what pre-commit install does. - Know what
git commit --no-verify skips, and why it shouldn't become a habit. - Open a second branch in its own folder with
git worktree add, and remove it afterwards.
Open, review and check out pull requests without leaving the terminal.
Today you will
- Install
gh (if you want it) and sign in with gh auth login. - Create, list, check out, view and merge pull requests from PowerShell.
- List and create issues, and follow GitHub Actions runs.
- Know which PowerShell quoting traps apply to
gh.
Blobs, trees, commits and refs: see how Git actually stores your work.
Today you will
- Name Git's three main objects, blob, tree and commit, and inspect each with
git cat-file. - Read
.git\HEAD and .git\refs\heads\main, and explain why a branch costs almost nothing. - Explain why amend and rebase always produce new commit ids.
- Tell loose objects from packfiles.