Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Cheat Sheet

Everything from the workshop on one page. Print it, or keep it open in a tab.

Git: set up once

CommandWhat it does
git config --global user.name "Your Name"The author name on your commits
git config --global user.email "you@example.com"The author email (use your GitHub email)
git config --global init.defaultBranch mainName the first branch main
git config --global pull.rebase falsegit pull merges (never asks how)
gh auth loginLet Git sign in to GitHub (GitHub CLI)

Git: start a repository

CommandWhat it does
git initMake the current folder a repository
git clone <url>Download a repository from GitHub, with all its history
git remote add origin <url>Connect a local repository to a GitHub one
git remote -vShow the connected remotes

Git: the daily loop

CommandWhat it does
git statusWhat changed? What is staged? Use it all the time
git diffThe exact changes not yet staged (--staged for staged ones)
git add <file> / git add .Stage a file / everything
git commit -m "Message"Save the staged snapshot
git commit -am "Message"Stage every modified tracked file and commit
git pushSend your commits to GitHub (-u origin <branch> the first time)
git pullFetch and merge others’ commits
git log --oneline --graphThe history, compact, with branches

Git: branches

CommandWhat it does
git branchList the local branches (* marks the current one)
git switch -c <name>Create a branch and switch to it
git switch <name>Switch to an existing branch
git fetch originDownload new commits from GitHub, without merging
git merge <branch>Merge a branch into the current one (e.g. origin/main)
git branch -d <name>Delete a merged local branch

Git: undo

CommandWhat it does
git restore <file>Discard uncommitted changes to a file
git restore --staged <file>Unstage a file (keeps the changes)
git commit --amend -m "..."Redo the last commit, before pushing it
git revert <hash>A new commit that undoes an old one: safe on shared history
git merge --abortCancel a merge in progress
git reset --hard origin/mainMake the current branch exactly like GitHub’s main, losing local work

Git: tags and releases

CommandWhat it does
git tag -a v1.0.0 -m "First release"Name the current commit v1.0.0
git push origin v1.0.0Publish the tag (tags are not pushed by git push)
git tagList the tags

Merge conflict: what to do

<<<<<<< HEAD
your version
=======
their version
>>>>>>> origin/main
  1. Edit the file into the final version, and delete the three marker lines.

  2. git add <file>

  3. git commit -m "Merge ..." (or git merge --abort to give up)

GitHub: linking work

Write thisWhereEffect
Closes #12 (or Fixes, Resolves)Pull request description or commit messageMerging into main closes issue #12
#12AnywhereLink to issue or pull request #12
@usernameIssue, PR or commentNotify that person
- [ ] taskIssue or PR bodyA checkbox; progress shows in lists

GitHub Actions: workflow skeleton

name: CI/CD                          # shown in the Actions tab

on:                                  # events that start the workflow
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:
    branches: [main]
  workflow_dispatch:                 # a "Run workflow" button

jobs:
  test:                              # job name = status check name
    runs-on: ubuntu-latest           # a fresh virtual machine
    steps:
      - uses: actions/checkout@v6    # a published action
      - run: pytest -v               # a shell command

  publish:
    needs: test                      # only after test succeeds
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      packages: write                # what GITHUB_TOKEN may do
    steps:
      - run: echo "${{ github.ref_name }}"   # contexts: github, secrets, matrix...

Useful contexts: github.repository (owner/name), github.ref_name (branch or tag), github.sha (commit id), github.actor (who triggered it), github.event_name (push, pull_request...), secrets.GITHUB_TOKEN.

Docker

CommandWhat it does
docker build -t calc-app .Build an image named calc-app from the Dockerfile in .
docker imagesList images
docker run --rm -p 8000:8000 calc-appRun a container; port 8000 of your machine → port 8000 of the container
docker run -d --name calc -p 8000:8000 calc-appThe same, in the background (-d), with a name
docker ps / docker ps -aRunning / all containers
docker logs calcA container’s output
docker stop calc / docker rm calcStop / delete a container
docker pull ghcr.io/<you>/calc-app:1.0.0Download an image from a registry
docker login ghcr.ioLog in to a registry (for private images)

Dockerfile instructions

InstructionMeaning
FROM python:3.12-slimThe base image to start from
WORKDIR /appFolder for the following instructions
COPY src destCopy files from your project into the image
RUN commandRun a command while building the image
EXPOSE 8000Document the port the app listens on
CMD ["program", "arg"]The command a container runs when it starts