GitHub Lesson 1: Core Fundamentals

From “knowing how to use Git” to “collaborating on the GitHub platform”: platform architecture, permission model, Issues/Projects, the PR workflow, gh CLI and API, community files, notifications and search
GitHub.comgh CLI 2.104.0Git 2.56Practice repository myappVerified against docs.github.com · 2026-11
Prerequisite course This lesson assumes you already know Git itself: commits, branches, merging, rebasing, remotes and pushing. If not, first complete the Git 8-hour course(at least Lessons 1–3). Git Lesson 3 already covered GitHub SSH/HTTPS authentication, ruleset basics, CODEOWNERS and the fork workflow, so this lesson does not repeat the low-level and authentication details, but ties them together from the platform perspective.
Overall learning goals
  • Draw the product and deployment landscape: GitHub.com, GitHub Enterprise Cloud (GHEC, including EMU and GHE.com data residency), and GitHub Enterprise Server (GHES), and the enterprise → organization → repository hierarchy; explain what Actions, Packages, Codespaces, GHAS (Secret Protection / Code Security) and Copilot each solve.
  • Master the permission model: the difference between personal repositories (owner + collaborators) and organization repositories, organization base permissions, the six preset repository roles (Read / Triage / Moderate / Write / Maintain / Admin), custom roles (GHEC only), nested team inheritance, outside collaborators, and the three visibilities public / private / internal.
  • Use Issues, sub-issues, issue types, labels, milestones, Projects (table/board/roadmap + custom fields + built-in automation) and Discussions to plan and track work.
  • Walk through the PR end-to-end workflow: draft PRs, review requests, suggested changes, required checks, ruleset evaluation, how the three merge methods affect the commit graph, and auto-merge.
  • Master the use of gh CLI (auth,repo,issue,pr,run) and gh api use REST and GraphQL directly, master pagination,--jq and rate limits.
  • Set up community files (README, issue forms, PR templates, CONTRIBUTING, SECURITY.md, CODEOWNERS, organization .github repository default files), use Markdown alert blocks and Mermaid well; configure notifications, use code search syntax, saved replies and keyboard shortcuts, and troubleshoot introductory problems such as 403/404, PRs that cannot be merged and gh authentication failures.

Hour 1 time allocation table

#TimeModuleCore contentAnimation / interactionLab (myapp repository)
0Before classEnvironment setupAccount and 2FA, installing gh (Windows / macOS / Linux),gh auth login, creating the myapp repository, optional free organization myorg-labEnvironment self-check listPush myapp to GitHub
100–06Platform overview and architectureGitHub.com / GHEC / GHE.com data residency / GHES; enterprise → organization → repository; product line positioningDeployment forms and hierarchy browserUse gh api to view account, organization and plan information
206–14Repositories, organizations, teams and permissionsBase permissions, six repository roles, custom roles, nested teams, outside collaborators, visibilityEffective permission calculator (take the highest across sources)Create teams, grant access, query effective permissions with the API
314–21Issues, Projects and DiscussionsLabels, milestones, issue types, sub-issues, Projects views and fields, built-in workflows, Discussionsissue → PR → close → board updates automaticallyCreate labels, milestones, parent/child issues and a project board
421–29Pull request end-to-end workflowDraft PRs, reviews, suggested changes, required checks, rulesets, three merge methods, auto-mergeCore animation: event flow of a PR from push to merge + how merge methods affect the commit graphDraft PR → ready → review → squash merge
529–37gh CLI and REST/GraphQL APIsgh auth,gh repo/issue/pr/run,gh api, pagination,--jq, rate limitsgh command → HTTP request translatorQuery PR data once with REST and once with GraphQL
637–43Markdown, templates and community filesREADME, issue forms, PR templates, CONTRIBUTING, SECURITY.md, CODEOWNERS,.github repository, MermaidCommunity file resolution order simulatorAdd issue forms and a PR template to myapp
743–50Notifications, search and productivityWatch strategies, notification inbox filtering, code search syntax, issue/PR search, saved replies, keyboard shortcutsSearch query builderSet up a “my to-do” search and notification filter
850–60Collaboration readiness review and troubleshootingRepository health checklist, 403/404, PR cannot be merged, notification overload, gh authentication failureReadiness scorer + interactive troubleshooting treeRun a readiness review on myapp with a script
—After classCheat sheet · Integrated labUse gh to complete issue → branch → PR → review → merge → auto-closed issue, and verify with the APICompletion quiz (12 questions)Integrated lab

Knowledge Coverage Matrix

Target skillM1M2M3M4M5M6M7M8Key commands / featuresLab
Explain deployment forms, hierarchy and product lines✓✓······GHEC / GHE.com / GHES, enterprise / orgM1 lab
Grant access by least privilege·✓·✓✓✓·✓Base permissions, repository roles, teams,/collaborators/{user}/permissionM2 lab
Plan and track work··✓✓✓✓✓·labels, milestones, sub-issues, ProjectsM3 lab
Complete and control one PR merge·✓✓✓✓✓·✓gh pr create/review/merge, rulesetsM4 lab · integrated lab
Automate with the CLI and API✓✓✓✓✓··✓gh api --paginate --jq, GraphQLM5 lab · integrated lab
Establish community and contribution standards··✓✓·✓·✓issue forms, PR templates, CODEOWNERS,.githubM6 lab
Manage the information flow and find things efficiently··✓···✓✓Watch,reason:,repo: path: symbol:M7 lab
Introductory platform troubleshooting·✓·✓✓·✓✓gh auth status,mergeStateStatusM8 lab

Topics excluded from this lesson (and where to learn them)

TopicWhy it is not in this lessonWhere to learn it
Git object model, merge/rebase principles, conflict resolutionBelongs to Git itselfGit Lesson 1,Lesson 2
SSH / HTTPS / GCM authentication, configuration details of rulesets and CODEOWNERS, forks and Inner SourceAlready covered in the Git courseGit Lesson 3
GitHub Actions workflow syntax, runners, caching, artifactsA separate major topicGitHub Lesson 2
OIDC deployment to Azure / AWSCloud platform topicGitHub Lessons 3 and 4
Reusable workflows, releases, supply-chain attestationsProduction-grade ActionsGitHub Lesson 5
GHAS (code scanning, secret scanning, push protection), organization rulesets, audit log, EMUEnterprise security and governanceGitHub Lesson 6
API rate limits in depth, ARC self-hosted runners, performance tuningDeep troubleshootingGitHub Lesson 7

How to use this course material

10 pages per module
Theory · diagrams · animation · commands · labs · production cases · troubleshooting · quiz · voice · video. Read “Theory” and “Animation” first, then do the “Lab” in your own myapp repository.
Study progress
A quiz score ≥ 70% or clicking “Mark this module complete” counts toward progress; it is saved in this browser (cleared on refresh if local storage is blocked).
Voice (zh-CN)
The “Voice” page reads the lecture script aloud using the browser's built-in Web Speech API (en-US); without a Chinese voice pack, the script can still be read or passed to a TTS tool.
Version notes GitHub.com is continuously delivered SaaS, and its interface and features change at any time. This lesson follows the 2026-11-15 version of docs.github.com; gh CLI baseline v2.104.0 (released 2026-11-12); commands are largely the same after 2.80; latest GHES is 3.22 (released 2026-09-08). Features on GHES and GHE.com may differ from GitHub.com, so when reading the docs first switch to the matching version in the upper-left corner. For features marked “plan requirement” in this course, follow the latest content of GitHub's plans and github.com/pricing as the authority.
Learning path This series runs in the order Linux → Bash → Git → Docker → Kubernetes → Terraform → Ansible → GitHub → GitLab → Azure DevOps → Jenkins → Azure Landing Zone → AKS → Helm → GitOps and Argo CD → Prometheus & Grafana. GitHub is the first course of the CI/CD platform group (GitHub / GitLab / Azure DevOps / Jenkins, choose one or two). The earlier Docker, Kubernetes and Terraform courses already covered images, clusters and infrastructure as code; this lesson puts them into GitHub Actions pipelines.

Module 0 · Environment setup (account, gh CLI, practice repository)

Prepare a GitHub account and 2FA, install and sign in to the gh CLI, push myapp as your practice repository, and optionally create the free organization myorg-lab
Before class ≈ 15 mingh 2.104.0Windows / macOS / Ubuntu 24.04
Prerequisites
  • One personal GitHub account (GitHub Free is enough to complete all required labs in this lesson); an email inbox that can receive mail; a TOTP authenticator app or a passkey device for two-step verification (2FA).
  • Installed Git 2.56 (same as Git course Module 0), configured user.name,user.email, default branch main.
  • (Optional) If you took the Docker course: the practice repository myapp is the Flask + gunicorn + Redis counter app from the Docker course. If you have not taken it, do not worry; the script below generates the same files.
  • (Optional) A second GitHub account or a partner, to experience “a peer reviewing your PR”. You can still complete the lesson without one: an author cannot approve their own PR, and this lesson gives a single-person alternative.

Connection to prerequisite courses

FromReused in this lessonNotes
Git Lessons 1–2commits, branches, merging, rebasing,push -uthis lesson operates only at the platform level and does not re-explain how Git commands work
Git Lesson 3SSH key or HTTPS + Git Credential ManagerIf already configured,gh auth login choose the same protocol when cloning
Docker Lesson 1myapp source (app.py, requirements.txt, Dockerfile, compose.yaml)Repository names are unified as myapp

Step 1: Account security (2FA)

On Settings → Password and authentication enable two-step verification; a passkey is recommended first passkey or a TOTP app, and download the recovery codes and store them in a password manager. GitHub requires accounts that contribute code on GitHub.com to enable 2FA; organizations can also require members and outside collaborators to enable 2FA (Module 2).

Note If you lose the recovery codes and the device, the account may become unrecoverable. Do not put recovery codes in a repository, chat history or a screenshot.

Step 2: Install the gh CLI

Windows 11

winget install --id GitHub.cli --source winget
# Upgrade
winget upgrade --id GitHub.cli
# After reopening the terminal
gh --version

macOS

brew install gh
# Upgrade
brew upgrade gh
gh --version

Ubuntu 24.04 / Debian (official apt source)

(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
 && sudo mkdir -p -m 755 /etc/apt/keyrings \
 && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
 && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
 && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
 && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
 && sudo apt update && sudo apt install gh -y
gh version 2.104.0 (2026-11-12)
https://github.com/cli/cli/releases/tag/v2.104.0

The gh package in Ubuntu's built-in repository gh is usually many versions behind, so use the apt source from the official cli/cli documentation above (commands taken from install_linux.md, which also gives the signing key fingerprint, which can be checked with gpg --show-keys ). gh versions below 2.80 lack some parameters used in this lesson (for example gh issue create --parent).

Step 3: Sign in to gh

gh auth login --hostname github.com --git-protocol https --web
gh auth status
gh auth setup-git          # let git get HTTPS credentials via gh (skip if you already use GCM or SSH)
! First copy your one-time code: 1A2B-3C4D
Press Enter to open https://github.com/login/device in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Logged in as your-login

github.com
  ✓ Logged in to github.com account your-login (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'gist', 'read:org', 'repo', 'workflow'

Mechanism: By default, sign-in uses a browser device flow, and the resulting OAuth token is stored in the system credential store (Windows Credential Manager / macOS Keychain / Linux Secret Service); if no credential store is found it falls back to a plaintext config file. Scripts and CI pass the token through the environment variable GH_TOKEN (Module 5).

Step 4: Create the myapp practice repository

Method A (recommended): If you already have the myapp directory from the Docker course, turn it directly into a GitHub repository:

cd ~/myapp                                  # the myapp directory from the Docker course
git init -b main 2>/dev/null; git add -A
git commit -m "chore: import myapp from Docker course" || true
gh repo create myapp --public --source=. --remote=origin --push \
  --description "Flask + Redis hit counter for the GitHub course"

Method B: If you do not have myapp, use the script below to generate the same files and then push:

mkdir -p ~/gh-lab/myapp && cd ~/gh-lab/myapp && git init -b main
cat > app.py <<'EOF'
import os
from flask import Flask, jsonify
from redis import Redis

app = Flask(__name__)
redis = Redis(host=os.getenv("REDIS_HOST", "redis"), port=6379, socket_timeout=2)


@app.route("/")
def hello():
    count = redis.incr("hits")
    return f"Hello from myapp! I have been seen {count} times.\n"


@app.route("/healthz")
def healthz():
    return jsonify(status="ok")
EOF
printf 'flask==3.1.*\nredis==6.*\ngunicorn==23.*\n' > requirements.txt
cat > Dockerfile <<'EOF'
FROM python:3.13-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]
EOF
cat > compose.yaml <<'EOF'
services:
  web:
    build: .
    ports: ["8000:8000"]
    environment: [REDIS_HOST=redis]
    depends_on: [redis]
  redis:
    image: redis:8-alpine
EOF
printf '# myapp\n\nA tiny Flask + Redis hit counter used throughout the Docker, Git and GitHub courses.\n' > README.md
printf '__pycache__/\n*.pyc\n.venv/\n.env\n' > .gitignore
git add -A && git commit -m "feat: initial myapp"
gh repo create myapp --public --source=. --remote=origin --push

Add a minimal CI (used to experience “required checks” in Module 4; workflow syntax is explained in detail in Lesson 2):

mkdir -p .github/workflows
cat > .github/workflows/ci.yml <<'EOF'
name: ci
on:
  pull_request:
  push:
    branches: [main]
permissions:
  contents: read
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7          # Lesson 5 covers pinning by SHA
      - uses: actions/setup-python@v7
        with:
          python-version: "3.13"
      - run: python -m py_compile app.py
EOF
git add .github/workflows/ci.yml && git commit -m "ci: add minimal lint workflow" && git push
✓ Created repository your-login/myapp on github.com
  https://github.com/your-login/myapp
✓ Added remote https://github.com/your-login/myapp.git
✓ Pushed commits to https://github.com/your-login/myapp.git
Why use public? On GitHub Free,private repositories cannot enforce branch protection/rulesets, required reviews or CODEOWNERS (these require Pro / Team / Enterprise on private repositories). Public repositories let you experience the full PR protection workflow on Free. Do not put any real secrets in the practice repository.

Alternative: If a repository is marked as a template repository (Settings → Template repository), you can use gh repo create myapp2 --public --template OWNER/TEMPLATE --clone to generate a new repository from the template. A template-generated repository has a fresh history (it is not a fork).

Step 5 (optional): create the free organization myorg-lab

Organizations can only be created on the web:github.com/account/organizations/new → choose Free → enter a globally unique organization name (for example myorg-lab-<your name>, referred to below as myorg-lab→ set ownership to “My personal account”. Then copy myapp into the organization:

ORG=myorg-lab                     # replace with your organization name
gh repo create $ORG/myapp --public --description "org copy of myapp"
cd ~/gh-lab/myapp   # or ~/myapp
git remote add org https://github.com/$ORG/myapp.git
git push org main

Environment self-check list

gh repo view --json name,visibility,defaultBranchRef --jq '{name, visibility, branch: .defaultBranchRef.name}'
gh run list -L 1
{"branch":"main","name":"myapp","visibility":"PUBLIC"}
STATUS  TITLE                         WORKFLOW  BRANCH  EVENT  ID           ELAPSED  AGE
✓       ci: add minimal lint workflow ci        main    push   19876543210  18s      1m

Module 1 · GitHub platform overview and architecture

00:00 – 06:00 · one platform, four deployment forms, a three-level account hierarchy, five product lines
6 minConceptual foundations★★★★☆
Learning objectives
  • Distinguish GitHub.com (Free / Pro / Team), GitHub Enterprise Cloud (GHEC, personal account model or EMU), GHEC data residency (GHE.com) and GitHub Enterprise Server (GHES), and state each one's data location, identity source and API address.
  • Draw the enterprise account → organization → repository/team hierarchy, and know at which level policies are set and how they take effect downward.
  • State the positioning and plan boundaries of Actions, Packages, Codespaces, GitHub Advanced Security (Secret Protection / Code Security) and Copilot.
Prerequisite knowledge: Git basics. Importance:★★★★☆ (before discussing any feature, first ask “in which deployment, on which plan, and at which level is it configured”)

What: what GitHub is

GitHub is a developer platform: Git handles version history, and on top of it GitHub provides identity and permissions, collaboration (Issues, PRs, Discussions, Projects), automation (Actions), artifacts (Packages), cloud development environments (Codespaces), security (Advanced Security, Dependabot) and AI (Copilot). These platform data is not stored in the Git repository: cloning a repository does not carry over its PRs, Issues, rulesets or Actions run records.

Why: why understand deployment forms and the hierarchy first

  • Whether a feature is available depends on the deployment form and plan: for example, internal visibility only exists for organizations under an enterprise account, custom repository roles are only in GHEC, and Copilot currently does not support GHES.
  • Compliance and data location: GitHub.com stores data in the US by default; choose GHE.com (EU / Australia / US / Japan) when data residency is needed, and GHES when full self-hosting is required.
  • Policy scope: enterprise-level policies (for example, forbidding public repositories or an Actions allowlist) constrain all organizations; organization-level settings constrain repositories. A common troubleshooting case, “why can't I change it as a repository admin?”, is caused by an upper-level policy locking the setting.

How: four deployment forms

GitHub.com (Free / Pro / Team)GHEC (personal account + SAML SSO)GHEC + EMU (on GitHub.com)GHEC data residency (GHE.com)GHES (self-hosted)
Hosted byGitHubGitHubGitHubGitHub (in a specified region)You (VM / cloud)
Access addressgithub.comgithub.com/enterprise's organizationgithub.com, usernames carry a _shortcode suffixSUBDOMAIN.ghe.comyour own domain
API addressapi.github.comapi.github.comapi.github.comapi.SUBDOMAIN.ghe.comHOST/api/v3,HOST/api/graphql
IdentityPersonal accountPersonal account + organization/enterprise SAML SSOManaged accounts provisioned by the IdP via SCIM; sign in via SAML or OIDCEMU onlyBuilt-in, LDAP, SAML, CAS
Public repositoriesYesYesNo (use internal for Inner Source)NoYes (visible only within the instance)
Data locationUS by defaultUS by defaultUS by defaultEU (including Azure regions in Norway and Switzerland) / Australia / US / JapanYou decide
Feature updatesContinuousContinuousContinuousContinuous (a few features not yet available)Released by version (currently 3.22); you must upgrade

How: account hierarchy

  • Personal account: each person has one; can own personal repositories; can belong to multiple organizations.
  • Organization: a shared account that owns repositories, teams, Projects, Packages, organization-level secrets and runners; has owners, members, outside collaborators and other roles.
  • Enterprise account: available only with GHEC / GHES; uniformly manages policies, billing, the audit log and identity (SAML / EMU) for multiple organizations.
  • Repository: code + platform data (Issues, PRs, Wiki, Actions, rulesets, environments, secrets).

Product line positioning

ProductWhat it solvesAvailability on Free accounts (2026-11 docs)See
GitHub ActionsEvent-driven CI/CD and automationPublic repositories use standard GitHub-hosted runners free of charge; private repositories include a monthly compute allowance of $12 (Pro / Team: $18; GHEC: $300)Lessons 2–5
GitHub PackagesHosted container images (ghcr.io), npm, Maven, NuGet and other packagesFree: 500 MB storage (Pro / Team: 2 GB; GHEC: 50 GB)Lessons 2 and 5
CodespacesCloud development containers (devcontainer)Personal accounts get 120 core-hours and 15 GB storage per monthLesson 7
GitHub Advanced SecuritySplit into Secret Protection (secret scanning, push protection) and Code Security (code scanning/CodeQL, dependency review, Copilot Autofix, security activity, etc.)Some features are enabled by default for public repositories; private/internal repositories need the Team or Enterprise planLesson 6
GitHub CopilotAI coding assistant, code review, coding agentCopilot Free (limited quota); personal paid Pro / Pro+ / Max; organizations Business / Enterprise; not available on GHESLessons 6 and 7

When: how to choose

  • Open-source projects and personal learning: GitHub Free; protected branches / CODEOWNERS on private repositories: Pro (personal) or Team (organization).
  • Companies that need SAML SSO, audit log streaming, IP allow lists and enterprise policies: GHEC; that need full control of the account lifecycle: GHEC + EMU.
  • Data must stay in the EU, Australia, Japan or similar regions, without self-operating: GHE.com.
  • Network isolation or regulation requires self-hosting: GHES (note the upgrade and capacity planning costs, and that Copilot is unavailable).

Comparison with similar platforms

GitHubAzure DevOpsGitLab
CoreRepositories + PRs + Actions + security + CopilotRepos + Boards + Pipelines + Artifacts + Test PlansOne application covering SCM through deployment
HierarchyEnterprise → organization → repositoryOrganization → project → repositoryInstance → group/subgroup → project
Self-hostedGHESAzure DevOps ServerGitLab Self-Managed
Work itemsIssues + Projects (lightweight)Boards (heavyweight work items, process templates)Issues + Epics
Common misconceptions (1) “GHEC is just a paid rename of GitHub.com”: it adds enterprise accounts, SAML/EMU, audit log streaming, data residency and fundamentally different governance capabilities. (2) “GHES has the same features as GitHub.com”: GHES is released by version, so features lag, and Copilot is unavailable. (3) “Organization owners are just ordinary admins”: organization owners have admin permission on every repository in the organization. (4) “Cloning a repository is a complete backup”: PRs, Issues, rulesets and Actions records are not in Git.

Architecture diagram: deployment forms and account hierarchy

GitHub-hosted (SaaS) GitHub.comFree / Pro / TeamPersonal account + organizationData stored in the US by default GHEC (github.com)Enterprise account + multiple organizationsSAML SSO or EMUAudit log streaming · IP allow list GHE.com data residencySUBDOMAIN.ghe.comEU / AU / US / JPEMU only, no public repositories GHES (self-hosted)Your data center / cloud VM · version 3.22GitHub Connect can connect to GHECCopilot unavailable enterprise account org: myorg-labowner · member · team org: platformrulesets · secrets · runners repo: myappcode + Issues/PR/Actions Policies take effect top-down:enterprise policy ⊇ organization settings ⊇ repository settingsWhen an upper level enforces a setting, lower levels see the option greyed out
Figure 1-1: four deployment forms; enterprise accounts exist only in GHEC / GHES and manage multiple organizations uniformly

Product line map: platform services touched by one commit

DeveloperIDE / Codespaces Repository + PRRulesets · CODEOWNERS ActionsCI / CD · check runs Advanced SecurityPush protection · CodeQL CopilotCompletion · code review · agents Packagesghcr.io images Issues / ProjectsCloses #N auto-close Cloud platformAzure / AWS OIDC federated credentials(Lessons 3 and 4)
Figure 1-2: a single push / PR touches several product lines: Actions writes back check status, GHAS scans, Copilot reviews, and the issue closes after merge

Interactive browser: what does the same requirement look like in different deployment forms?

Select a deployment form first, then click a requirement. The right side shows the URL, identity source, data location, whether the requirement can be met, and which plan it needs. Data comes from docs.github.com (GitHub's plans, About GHEC with data residency, GHES releases), verified 2026-11-15.

Select a deployment form
then select a requirement
# The corresponding API endpoint is shown here

Core commands: use gh to see “where you are, who owns it, and what plan it is”

CommandPurposeNotes
gh auth statusCurrently logged-in host, account, token scopesWhen multiple hosts are used (github.com + GHE.com + GHES), all are listed
gh api userCurrent user informationincludes plan (visible only to yourself),two_factor_authentication
gh api user/memberships/orgswhich organizations I belong to and my role in eachrole: admin (owner) or member
gh api orgs/ORGOrganization informationOwners can see plan,default_repository_permission (base permissions)
gh auth login --hostname SUBDOMAIN.ghe.comSign in to GHE.com / GHESand then use GH_HOST or -R HOST/OWNER/REPO to select the host
gh api metaGitHub.com IP ranges, SSH fingerprints, etc.Firewall allow rules, SSH known_hosts verification
gh api user --jq '{login, type, plan: .plan.name, twofa: .two_factor_authentication, created_at}'
{"created_at":"2019-03-02T08:11:45Z","login":"your-login","plan":"free","twofa":true,"type":"User"}
gh api user/memberships/orgs --jq '.[] | {org: .organization.login, role, state}'
{"org":"myorg-lab","role":"admin","state":"active"}
gh api orgs/myorg-lab --jq '{login, plan: .plan.name, base: .default_repository_permission, two_factor_requirement_enabled, public_repos}'
{"base":"read","login":"myorg-lab","plan":"free","public_repos":1,"two_factor_requirement_enabled":false}

How to read it:default_repository_permission is the organization's base permission (Module 2); possible values are read,write,admin,none. When called by a non-owner, plan and similar fields are not returned. This itself reflects the permission model.

# Using both github.com and GHE.com on the same machine (example subdomain octocorp)
gh auth login --hostname octocorp.ghe.com
gh auth status
GH_HOST=octocorp.ghe.com gh api user --jq .login
gh repo list octocorp-org -L 5 --json name --jq '.[].name'    # still uses the default host github.com

Common mistake: Thinking that after signing in to GHE.com all commands go to GHE.com. In fact gh determines the host from the git remote of the current directory or GH_HOST/-R , otherwise it defaults to github.com.

Lab 1: profile your own GitHub environment (about 4 min)

Goal: use the API to confirm account type, plan, 2FA and organization roles, and distinguish “Git data” from “platform data”. Environment: myapp after completing Module 0.
Account and organization:
gh api user --jq '{login, plan: .plan.name, twofa: .two_factor_authentication}'
gh api user/memberships/orgs --jq '.[] | "\(.organization.login)\t\(.role)"'

If twofa is false, first go back to Module 0, Step 1.

View GitHub.com network metadata (to understand that “the platform” is a group of services):
gh api meta --jq '{ssh_key_fingerprints, git: (.git | length), actions: (.actions | length), packages: (.packages | length)}'
{"actions":8350,"git":107,"packages":30,"ssh_key_fingerprints":{"SHA256_ECDSA":"p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM","SHA256_ED25519":"+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU","SHA256_RSA":"uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s"}}

The SSH fingerprints can be compared with the known_hosts verification in Git Lesson 3; actions is the egress IP range of GitHub-hosted runners, used in Lessons 3 and 4 for cloud firewalls.

Proving platform data is not in Git:
cd ~/gh-lab/myapp     # or ~/myapp
gh issue create --title "test: platform data" --body "this lives in GitHub, not in .git"
git fetch origin && git log --all --oneline | head -3
git ls-remote origin | head -5

The issue is created successfully, but git log and ls-remote contain no new objects. Issues, PR discussions and rulesets are in GitHub's database. (PRs are an exception: they do produce refs/pull/N/head on the server; you will see this in Module 4.)

Cleanup:
gh issue list --search "test: platform data" --json number --jq '.[].number' | xargs -I{} gh issue close {} --reason "not planned"

Case 1: a European company migrates from GHES to GHE.com

Problem: A company subject to GDPR runs GHES; upgrades require downtime every quarter, and the security team also wants to use Copilot (not supported on GHES). Approach: Choose GHEC data residency (EU region), provision EMU accounts via SCIM from the IdP (Entra ID), and migrate repositories and PR history with GitHub Enterprise Importer. Configuration: Change the API endpoint on developer machines and in CI to api.SUBDOMAIN.ghe.com, allow the firewall per the GHE.com network documentation, and gh uses gh auth login --hostname SUBDOMAIN.ghe.com. Limitations: GHE.com has no public repositories; EMU accounts cannot interact directly with open-source projects on github.com; some features are temporarily unavailable, so check the official “Feature overview” list.

Case 2: “Why can I not see the public option as a repository admin?”

Problem: A team lead wants to open-source an internal tool, but the visibility options in Settings show only private / internal. Root cause: An enterprise owner has forbidden members from creating or changing repositories to public in the enterprise policy. Approach: Go through the open-source approval process, with an enterprise or organization owner publishing in a dedicated open-source organization. Lesson: When troubleshooting, first ask “which level controls this setting?”

Case 3: a clone is not a platform backup

Problem: An organization accidentally deleted a repository; an admin re-pushed the code from a clone on one machine, and the code came back, but 300 PR discussions, Issues, rulesets and Actions secrets were all lost. Approach: A deleted repository can be restored by organization owners in Settings for a period of time (follow the official documentation for the exact period). The long-term solution is to use migration/backup APIs or third-party backup products to export platform data regularly. Lesson: Git data and platform data need separate backup strategies.

Common errors and fixes

HTTP 404: Not Found (https://api.github.com/orgs/myorg-lab)

Cause: The organization name is misspelled, or you are using the wrong host (the organization is on GHE.com/GHES). GitHub also returns 404 for private resources you have no access to, so as not to reveal their existence.

gh auth status
gh api user/memberships/orgs --jq '.[].organization.login'

Fix: Use the correct organization name; for GHE.com/GHES resources add --hostname or set GH_HOST.

gh: Resource not accessible by personal access token (HTTP 403)

Cause: A fine-grained PAT does not cover the organization/repository or lacks the needed permissions; or the organization enables SAML SSO and the token is not authorized.

Fix: Check the fine-grained PAT's “Resource owner”, repository list and permissions; for SSO-enabled organizations, use “Configure SSO → Authorize” for that organization on the tokens page. For interactive use, it is recommended to use directly gh auth login. (Modules 5, 8)

Option greyed out in the UI: “This setting has been set by enterprise administrators”

Cause: An enterprise-level or organization-level policy enforces this setting.

Fix: Contact the upper-level owner; do not try to “bypass” it at the repository level.

A feature in the docs cannot be found here

Cause: The wrong docs version is selected (Free/Pro/Team vs Enterprise Cloud vs Enterprise Server 3.x), or your plan does not include the feature, or the feature is in public preview.

Fix: Switch the version at the upper left of docs.github.com; check the “Who can use this feature” note at the top of the page; compare against GitHub's plans.

Command-line questions
1. One command that lists all organizations you belong to and your role in each.
gh api user/memberships/orgs --jq '.[] | "\(.organization.login) \(.role)"'
2. You work on both github.com and octocorp.ghe.com. How do you run a single gh api user for GHE.com only?
GH_HOST=octocorp.ghe.com gh api user --jq .login
# or: gh api --hostname octocorp.ghe.com user
Scenario analysis
A Japanese financial company requires: code stored in Japan, employees sign in with the company Entra ID, they want to use Copilot, and they do not want to run servers themselves. Which deployment should be chosen, and what are the costs?

Choose GHEC data residency (GHE.com, Japan region) + EMU. This meets the data location requirement, gives unified identity from the IdP (SCIM provisioning + SAML/OIDC), requires no operations, and can grant Copilot Business/Enterprise. Costs: public repositories cannot be created; EMU accounts cannot take part in open-source collaboration on github.com (a separate personal account is needed); the API and network endpoints change to *.ghe.com, and some features are temporarily unavailable and need checking against the list. GHES can be placed in Japan, but it requires self-operation and does not support Copilot.

Verified instructional videos

▶
What is GitHub? — GitHub
English · official channel · a quick overview of GitHub as a collaboration platform
▶
How GitHub works — GitHub
English · official channel · how repositories, branches and PRs work overall
▶
Answering the most common GitHub beginner questions — GitHub
English · GitHub for Beginners series · common questions such as the difference between Git and GitHub

Official documentation

Video storyboard script (about 90 seconds)

This course material cannot directly generate video or MP3 files; storyboards and narration scripts are provided for use with a video tool.

Shot 1 · 0–20s
Scene: a Git repository cylinder, with Issues, PR, Actions, Packages, Security and Copilot icons lighting up one by one around it.
Narration: Git manages history; GitHub adds collaboration, automation, security and AI around the repository. None of this platform data is in .git.
Shot 2 · 20–50s
Scene: four boxes from left to right: github.com, GHEC, GHE.com (the EU, Australia, US and Japan light up on a map), GHES (a machine room).
Narration: the same product comes in four forms; the differences are where the data sits, where identity comes from, and when features are updated.
Shot 3 · 50–75s
Scene: an enterprise account with two organizations attached, with repositories and teams under the organizations; a “policy” flows from top to bottom and greys out a switch in the repository settings.
Narration: enterprises manage organizations, and organizations manage repositories. A setting enforced at the upper level can be viewed but not changed at the lower level.
Shot 4 · 75–90s
Scene: terminal runs gh api user/memberships/orgs; output shows organizations and roles.
Narration: one command confirms where you are, who you belong to, and what role you have. In the next module we dig into the permission model.
or get a score of ≥ 70% in the quiz

Module 2 · Repositories, organizations, teams and the permission model

06:00 – 14:00 · effective permission = the highest across all grant sources; organization owners are always admin
8 min6 preset repository rolesCustom roles: GHEC only★★★★★
Learning objectives
  • Explain the difference between personal repositories (two levels: owner + collaborators) and organization repositories (fine-grained roles), and know when to transfer a personal repository to an organization.
  • State the boundaries of the six preset repository roles Read / Triage / Moderate / Write / Maintain / Admin, and combine them with organization base permissions, teams (including nested inheritance) and outside collaborators to work out a person's effective permissions.
  • Understand the public / private / internal visibilities and their relationship to forks, as well as the plan requirements for custom repository roles and custom organization roles (GHEC).
Prerequisite knowledge: Module 1. Importance:★★★★★ (almost every 403/404 is related to this)

What: two kinds of repository ownership

Personal account repositoryOrganization repository
Permission levelsOnly two levels: owner (full control) and collaboratorSix preset roles + base permissions + teams + (GHEC) custom roles
What collaborators can doA fixed set of permissions: push, manage issues/PRs, etc.; cannot change visibility, invite others or delete the repositoryDetermined by the assigned role
Suitable forpersonal projects and small-scale collaborationteams, companies, anything needing division of labour and auditing
Upgrade pathWhen finer-grained permissions are needed,transfer the repository to an organization; GitHub redirects the old URLs

People in an organization

  • Organization owners: fully manage the organization and have every repository admin permission in the organization. Recommended: at least 2 people, but not too many.
  • Members: subject to base permissions, then layered with team and direct grants.
  • Outside collaborators: not organization members; only granted access to certain repositories; not affected by base permissions and cannot join teams. Apart from the Free plan, outside collaborators accessing private repositories consume one paid seat; if the organization requires 2FA, they must also enable 2FA before accepting an invitation.
  • Other organization roles (such as billing manager, security manager, moderator, etc.) are for specialised duties; see “Roles in an organization” for details.

Base permissions

Organization owners set this in Settings → Member privileges → Base permissions, applying to all members for access to all repositories in the organization minimum permission, selectable as No permission / Read / Write / Admin. Key points: it does not apply to outside collaborators; changes affect both new and existing members; if a member is individually granted a higher role, the higher one applies; internal repositories are at least read for enterprise members even when base permissions are set to none.

Six preset repository roles (from lowest to highest)

RoleDesigned forTypical capabilities (excerpted from the official permissions table)Cannot do
ReadPeople who only need to view and discussClone/pull, fork, open issues, comment, submit review comments (not an approving “required review”)Push, apply labels, close others' issues
TriagePeople who actively organize issues/PRs but do not write codeAdd/remove labels and milestones, assign, close/reopen All issues and PRs, mark duplicates, request reviewsPush, merge, give valid approval in “required reviews”
ModerateCommunity moderatorsOn top of Triage, can moderate and edit issues and discussions (for example edit others' issue titles/bodies and comments, hide comments, lock issue conversations), and manage PRs. Still no write permissionPush, merge
WritePeople who contribute code day to dayPush branches,merge PRs, valid approvals/request changes, enable auto-merge, manage Actions workflows and secrets, publish releases, act as a code ownerChange repository settings, manage access, manage rulesets
MaintainProject managers / maintainersWrite + edit description and topics, configure PR merge methods, enable Wiki/Discussions, configure Pages, limit interactionsSensitive/destructive actions: delete repository, change visibility, manage access, manage rulesets
AdminPeople who need full controlEverything: manage access and teams, rulesets and branch protection, webhooks and deploy keys, security feature settings, change visibility, change the default branch, archive/delete/transfer—

Moderate is a newer role, already on the official “Repository roles for an organization” page when this course was written; for its subtle differences from Triage (for example for certain discussion actions), follow the official permissions table.

Teams

  • A team is a group of members that can be granted a repository role as a whole, @mentioned, requested as reviewers, and written into CODEOWNERS.
  • Visibility: visible (all members can see it; in the API privacy=closed) or secret (visible only to team members and owners); secret teams cannot be nested.
  • Nesting: a parent team can have multiple child teams, and each child team has only one parent team. Child teams inherit the parent team's repository permissions, and when a parent team is @mentioned, members of child teams are also notified; child-team members are not direct members of the parent team.
  • GHEC can also use IdP groups to sync team membership (team synchronization), and create teams at the enterprise level.

Visibility

VisibilityWho can see itAvailable scopefork
publicEveryone on the internet (on GHES, all users of the instance)All plans (except EMU / GHE.com)Anyone can fork; forks are public
privateOwners and authorized people; organization repositories also include members who can see it under base permissionsAll plansThe organization can set whether private forks are allowed
internalMembers of all organizations in the enterprise (at least read)Only organizations under an enterprise account (GHEC / GHES)Forks stay within the enterprise

How: calculating effective permissions

  1. Organization owner → admin, done.
  2. Otherwise collect all sources: base permissions (members only), the grant of each team the person belongs to (including inherited from parent teams), direct grants, and the implicit read from internal/public.
  3. Take the highest one. GitHub's repository roles take the maximum; there is no “deny takes precedence” concept. To restrict someone, you can only remove the source that grants them the high permission.
  4. Rulesets/branch protection are another layer: even with Write, a rule may prevent direct pushes to main (Module 4).

Custom roles (plan requirements)

  • Custom repository roles: only organizations using GitHub Enterprise Cloud can create them. They inherit from one of Read / Triage / Write / Maintain and then add extra fine-grained permissions (for example “Write + manage webhooks”).
  • Custom organization roles: grant permissions over all existing and future repositories or organization settings (unlike repository roles, which apply to specific repositories); likewise, follow the GHEC documentation.

When: best practices for granting access

  • Set base permissions to Read or No permission; grant access by team rather than directly to individuals (for audit and offboarding).
  • Use nested teams to map the organizational structure: Engineering (read) → Backend (write on the api repository) → Backend-Leads (maintain).
  • Only a very small number of people should have Admin; day-to-day maintainers use Maintain.
  • External contractors use outside collaborators with a scheduled access review; deployment machines use deploy keys or a GitHub App rather than a personal account.
Common misconceptions (1) “Adding someone to a read team lowers their permission”: no, the maximum applies, so write access from other teams or base permissions still counts. (2) “Triage can approve PRs to satisfy required reviews”: no, valid approval requires Write or above. (3) “Outside collaborators are also bound by base permissions”: no, they are not; they only have the repositories directly granted to them. (4) “Maintain can change branch protection”: no, rulesets and branch protection are Admin only. (5) “Free organizations can also create custom roles”: only GHEC can.

Permission source diagram: where a person's effective permissions come from

Organization base permissionsmyorg-lab: Read Parent team engineeringmyapp: Triage Child team backendmyapp: Write (inherits Triage) Direct grantNone Organization owner? No max( )No deny; only the highest is taken alice's effective role on myappWriteThen passes through rulesets: can push branches, cannot push directly to main Outside collaborator: only the “direct grant” line appliesOrganization owner: direct AdminInternal repository: enterprise members get at least Read
Figure 2-1: effective permission = the maximum across all sources; rulesets are another gate layered on top

Role ladder: what each step adds

ReadView, clone, open issues TriageLabels, assignment, closingRequest reviews ModerateEdit/hide others' contentLock conversations WritePush, merge PRsValid approvalActions secrets MaintainMerge method settingsTopics, PagesEnable Discussions AdminManage accessRulesets / branch protectionVisibility, deletionWebhooks, security settings No write permission ←→ Has write permission
Figure 2-2: Write is the dividing line for “can change code”; Admin is the dividing line for “can change rules”

Interactive calculator: what is this person's effective permission on myapp?

Adjust each grant source on the left; the right side shows the effective role in real time, its source, and the typical “can / cannot” operations. The rules match the official documentation: organization owners are always Admin; outside collaborators ignore base permissions and teams; internal repositories give enterprise members at least Read; the maximum across sources applies.

Core commands (gh + REST API)

TaskCommandNotes
Check someone's effective permissiongh api repos/OWNER/REPO/collaborators/USER/permissionrole_name is the true role; permission is the legacy mapping (maintain→write, triage→read)
List collaboratorsgh api repos/OWNER/REPO/collaborators --jq '.[] | [.login, .role_name] | @tsv'affiliation=outside|direct|all
Invite an outside collaboratorgh api -X PUT repos/ORG/REPO/collaborators/USER -f permission=triagepermission: pull,triage,push,maintain,admin or a custom role name
Create team / child teamgh api orgs/ORG/teams -f name=backend -f privacy=closed -F parent_team_id=IDA secret team cannot have a parent team
Grant a team a repository rolegh api -X PUT orgs/ORG/teams/backend/repos/ORG/REPO -f permission=pushSame permission values as above
Invite a member / join a teamgh api -X PUT orgs/ORG/memberships/USER -f role=member; gh api -X PUT orgs/ORG/teams/backend/memberships/USERthe invitee needs to accept the invitation
Set base permissionsgh api -X PATCH orgs/ORG -f default_repository_permission=readRequires organization owner
Change visibilitygh repo edit ORG/REPO --visibility private --accept-visibility-change-consequencesRequires Admin; changing public → private loses stars/watches, etc.
Transfer a personal repository to an organizationgh api repos/USER/REPO/transfer -f new_owner=ORGOld URLs redirect automatically
ORG=myorg-lab
gh api repos/$ORG/myapp/collaborators/$(gh api user --jq .login)/permission --jq '{permission, role_name, user: .user.login}'
{"permission":"admin","role_name":"admin","user":"your-login"}
# Create parent and child teams and grant access
PARENT_ID=$(gh api orgs/$ORG/teams -f name=engineering -f privacy=closed --jq .id)
gh api orgs/$ORG/teams -f name=backend -f privacy=closed -F parent_team_id=$PARENT_ID --jq '{slug, parent: .parent.slug}'
gh api -X PUT orgs/$ORG/teams/engineering/repos/$ORG/myapp -f permission=triage
gh api -X PUT orgs/$ORG/teams/backend/repos/$ORG/myapp -f permission=push
gh api orgs/$ORG/teams/backend/repos --jq '.[] | {repo: .full_name, role: .role_name}'
{"parent":"engineering","slug":"backend"}
{"repo":"myorg-lab/myapp","role":"write"}

Note: The API writes push, while the return value and UI display write; likewise pull↔read. Calling PUT on a team returns no content (HTTP 204), which is normal.

Lab 2: build a minimum-permission structure in myorg-lab (about 6 min)

Goal: base permission Read; two-level teams engineering (Triage) → backend (Write); outside collaborator read-only; verify effective permissions with the API. Environment: the optional organization myorg-lab from Module 0 and myorg-lab/myapp. Learners without an organization can read along and complete step 5 on a personal repository.
Set base permissions:
ORG=myorg-lab
gh api -X PATCH orgs/$ORG -f default_repository_permission=read --jq .default_repository_permission
read
Create teams and grant access: run the team script from the “Commands” page. Then view the hierarchy on the web https://github.com/orgs/myorg-lab/teams (backend appears under engineering).
(when you have a partner) invite a member to backend, or invite them as an outside collaborator:
BUDDY=buddy-login            # the partner's username
gh api -X PUT orgs/$ORG/teams/backend/memberships/$BUDDY --jq .state      # pending; becomes active after acceptance
# Or: outside collaborator, read-only
gh api -X PUT repos/$ORG/myapp/collaborators/$BUDDY -f permission=pull --jq '.permissions'

Inviting a team member also invites them to join the organization. After they accept, check effective permissions again:

gh api repos/$ORG/myapp/collaborators/$BUDDY/permission --jq '{permission, role_name}'
{"permission":"write","role_name":"write"}
Personal repository comparison: invite a collaborator on the personal repository myapp (there is only one collaborator permission):
gh api -X PUT repos/$(gh api user --jq .login)/myapp/collaborators/$BUDDY --jq '.permissions'

Personal repositories cannot choose Triage/Maintain. This is one of the reasons an organization is needed.

Verify “take the highest”: change engineering to Maintain; the effective role of a backend member becomes maintain (child teams inherit from the parent team and the maximum applies):
gh api -X PUT orgs/$ORG/teams/engineering/repos/$ORG/myapp -f permission=maintain
gh api repos/$ORG/myapp/collaborators/$BUDDY/permission --jq .role_name     # maintain
gh api -X PUT orgs/$ORG/teams/engineering/repos/$ORG/myapp -f permission=triage   # change back
Cleanup (optional): keep the teams for later courses; if not needed:
gh api -X DELETE orgs/$ORG/teams/backend
gh api -X DELETE orgs/$ORG/teams/engineering
gh api -X DELETE repos/$ORG/myapp/collaborators/$BUDDY

Case 1: a departed employee can still push code

Problem: An employee was removed from the backend team after leaving, and a week later it was found that they had still pushed commits. Root cause: Two years earlier they had been added individually as a direct collaborator (Write) on a repository; removing them from the team does not affect direct grants. In addition, they had added a writable deploy key. Approach: Remove the member from the organization (this also removes all teams and direct grants), and audit deploy keys and PAT/SSH authorizations; standardize “grant access only by team”. On GHEC, SCIM/EMU lets disabling the account in the IdP take effect automatically. Lesson: The official documentation specifically warns that a deploy key holder can still access the repository even after leaving the organization.

Case 2: a community maintainer should be able to organize issues without touching code

Approach: In an open-source project, give volunteers Triage (apply labels, close duplicates) or Moderate (can also edit/hide others' content and lock heated issues); core maintainers get Write/Maintain, with only 2 Admins. Limitation: Approvals from Triage/Moderate do not count toward required reviews.

Case 3: Inner Source with internal repositories

Problem: A company's 30 organizations want to share an internal SDK without making it public, and without granting access one by one. Approach: Set the SDK to internal under the GHEC enterprise account: all enterprise members can read it automatically and fork it (forks stay within the enterprise); contributions go through PRs; the maintaining team gets Maintain. Limitation: Outside collaborators cannot see internal repositories and need separate access; Free/Team organizations do not have internal.

Common errors and fixes

remote: Repository not found. fatal: repository 'https://github.com/myorg-lab/myapp.git/' not found

Cause: There is no access at all to the private repository (GitHub returns “not found” rather than “forbidden”), or the credential belongs to another account, or SAML SSO is not authorized.

gh auth status
gh api repos/myorg-lab/myapp --jq .full_name
git credential-manager github list 2>/dev/null   # if using GCM

Fix: Confirm the account and ask an administrator for access; SSO organizations must complete SSO authorization in the browser or authorize the token. (Module 8 troubleshooting tree)

remote: Permission to myorg-lab/myapp.git denied to alice. (HTTP 403)

Cause: You can see the repository (Read/Triage/Moderate) but do not have Write.

gh api repos/myorg-lab/myapp/collaborators/alice/permission --jq .role_name

Fix: Request to join a team with Write, or fork and submit a PR (the usual open-source practice).

“I moved him to a read-only team, but he can still push”

Cause: The maximum applies: base permissions, other teams, the parent team, or a direct grant still gives Write.

Fix: Check each of his access sources under the repository's Settings → Collaborators and teams (the UI shows “via team X”), and remove them one by one.

HTTP 422: Validation Failed — parent_team_id ... secret teams cannot be nested

Cause: Attempting to make a secret team a child or parent team.

Fix: When creating, use -f privacy=closed (visible).

The “Create custom role” button does not exist

Cause: Custom repository roles apply only to GitHub Enterprise Cloud organizations. Alternative: Use preset roles plus team combinations; request a GHEC trial if needed.

Command-line questions
1. List all outside collaborators of myorg-lab/myapp and their roles.
gh api "repos/myorg-lab/myapp/collaborators?affiliation=outside" --jq '.[] | "\(.login)\t\(.role_name)"'
2. Change the backend team's permission on myapp to Maintain.
gh api -X PUT orgs/myorg-lab/teams/backend/repos/myorg-lab/myapp -f permission=maintain
Scenario analysis
The organization base permission is Write, and the security team requires that interns can only read the payments repository. You put the intern in the payments-readers team (Read), but it did not take effect. Why, and what is the correct approach?

The effective permission is the highest value across all sources; the base permission Write still applies to the intern, and a Read team cannot “reduce” permission. Correct approach: lower the organization base permission to Read or No permission, grant the people who need it Write through teams (for example, the payments-devs team with Write), and keep interns only in payments-readers (Read); or make the intern an outside collaborator (not subject to base permissions). Also use a ruleset to protect main as a second line of defence.

Verified instructional videos

▶
How to create your first GitHub repository: A beginner's guide | Tutorial — GitHub
English · official channel · creating repositories and choosing visibility
▶
Git and GitHub for Beginners - Crash Course — freeCodeCamp.org
English · about 1 hour · basic operations including collaborators and repository settings

No verified video specifically explaining organization roles and team nesting was found; follow the official documentation below and the storyboard script.

Official documentation

Video storyboard script (about 100 seconds)

Shot 1 · 0–20s
Scene: on the left, a personal repository has only two keys, “owner + collaborator”; on the right, an organization repository has six keys from light to dark.
Narration: a personal repository has only two permission levels; an organization repository has six preset roles, from Read to Admin.
Shot 2 · 20–50s
Scene: five pipes (base permissions, parent team, child team, direct grant, owner) flow into a funnel labelled max, which outputs Write.
Narration: a person's effective permission comes from multiple sources, and GitHub takes the highest one; there is no “deny takes precedence”.
Shot 3 · 50–80s
Scene: the backend team hangs under the engineering team and permissions flow downward; a secret team tries to attach and is blocked by a red cross.
Narration: child teams inherit parent-team permissions; secret teams cannot be nested. Outside collaborators do not join teams and are not affected by base permissions.
Shot 4 · 80–100s
Scene: the terminal runs collaborators/USER/permission; the output shows role_name.
Narration: when you suspect a permission problem, first check the effective role via the API, then check each source one by one.
or get a score of ≥ 70% in the quiz

Module 3 · Issues, Projects and Discussions

14:00 – 21:00 · Issues record “what to do”, Projects answer “who is doing it and how far along”, Discussions hold “things not yet decided”
7 minSub-issues and issue types are GA★★★★☆
Learning objectives
  • Use labels, milestones, assignees,issue types and sub-issues to organize work, and be able to create and edit them in bulk with the gh CLI.
  • Create Projects, using table / board / roadmap views, custom fields (single select, iteration, number, date, text) and built-in automated workflows.
  • Know when to use an Issue and when to use a Discussion; link PRs to issues with closing keywords (Closes #N).
Prerequisite knowledge: Module 2 (Triage and above can manage labels and assignments). Importance:★★★★☆

What: three tools, three kinds of information

IssuesProjectsDiscussions
NatureTrackable work items in a repository (bugs, tasks, features)Cross-repository planning views (table / board / roadmap), owned by users or organizationsOpen-ended conversations (Q&A, ideas, announcements, polls)
Statusopen / closed (close reasons: completed, not planned, duplicate)Expressed by custom fields (such as Status, Iteration)The Q&A category can be “marked as answer”
Suitable forwork that is “decided to be done”scheduling, tracking progress, cross-team roadmapsthings “not yet decided whether to do”; community support
Conversionissues ↔ discussions can be converted into each other; issues and PRs (and draft issues) can both be added to a Project

Issue metadata

  • Labels: repository-level; new repositories come with bug,documentation,duplicate,enhancement,good first issue,help wanted,invalid,question,wontfix; the organization can set default labels for new repositories. good first issue will make the issue appear on the repository's Contribute page.
  • Milestones: a group of issues/PRs + a due date + a completion percentage, often corresponding to one release (for example v1.2.0).
  • Issue types: a category at the organization (or personal account) level, with defaults task / bug / feature, up to 25 types, editable, disableable and deletable; can be filtered in search and in Project views. Difference from labels: a type answers “what kind of work is this”, and each issue has only one; labels are multi-select attributes.
  • Sub-issues: split a large issue into tasks. Each parent issue can have up to 100 sub-issues, nested up to 8 levels, and they can span repositories; the parent issue shows completion progress, and Projects can group or filter by parent issue.
  • Assignees,linked branches and PRs (Development sidebar),relationships (blocked by / blocking; follow the official documentation).

Projects

  • View layouts: Table (dense table), Board (kanban), Roadmap (timeline). Each view can save its own filters, sorting, grouping and slices.
  • Fields: built-in (Assignees, Labels, Milestone, Repository, Parent issue, Sub-issue progress, etc.) + custom: text, number, date, single select, iteration (break periods such as holidays can be set). A project can have at most 50 fields; the project item limit was raised in April 2025 to 50,000.
  • Automation: (1) built-in workflows: for new projects enable two by default: Status is set to Done when an issue/PR is closed, and when a PR is merged; others (such as setting Todo when an item is added, or closing an issue when the status changes) must be turned on manually; (2) auto-add (by repository + filter conditions) and auto-archive; (3) the GraphQL API and Actions (Lesson 2).
  • Other: Insights charts, project templates (organization level), status updates (On track / At risk).

Closing keywords: automatic linking of PRs and issues

Write in the PR description (or commit message) close/closes/closed,fix/fixes/fixed,resolve/resolves/resolved + #N (for a cross-repository issue, write OWNER/REPO#N), the PR is linked to the issue in Development,and when the PR is merged into the default branch, the issue is closed automatically. Merging into another branch (for example release/1.x) does not close it automatically; this is the most common “why wasn't it closed?” case.

Discussions

Enabled for a repository or organization by an admin (Maintain also works). Organized by category organization (Announcements, General, Ideas, Polls, Q&A, Show and tell, etc.; customizable, and category form templates can be used). Suitable for: user questions, RFC feedback requests, release announcements, and moving “non-bug questions” out of Issues.

When: a selection guide

ScenarioWhat to use
A user reports “/healthz returns 500”Issue (type bug, label area/api), add to Project
“Should we replace Redis with Valkey?”Discussion (Ideas); convert to an issue once consensus is reached
“What work does the v1.2 release include?”Milestone v1.2.0 + the Roadmap view of a Project
A feature needs 5 steps across 2 repositoriesParent issue (feature) + cross-repository sub-issues
Iteration planning every two weeksProject's Iteration field + a board grouped by iteration

Comparison with similar tools

GitHub Issues + ProjectsJiraAzure Boards
Distance from codeSame platform; closing keywords and the Development sidebar link nativelyVia integrations (Smart Commits, etc.)Native in Azure Repos; GitHub integrates via AB#123
Process customizationLightweight: fields + views + workflowsStrong: workflow schemes, permission schemesProcess templates (Agile/Scrum/CMMI)
HierarchySub-issues (8 levels)Epic → Story → Sub-task (extensible)Epic → Feature → PBI → Task
Common misconceptions (1) “If a PR says Closes #3, the issue will definitely close after merge”: only when it is merged into the default branch does it close. (2) “A Project is part of the repository”: current Projects belong to users or organizations and can span repositories; deleting a repository does not delete the project (but removes its items from it). (3) “The more labels the better”: label sprawl makes filtering ineffective; structured information such as type and priority is better expressed with issue types or Project fields. (4) “A Discussion is just a forum version of an issue”: it has no assignees or milestones, and PRs do not close it.

Data model: issues, sub-issues, Project items and PRs

#10 feature: version informationType feature · Milestone v1.2.0Sub-issue progress 1/3 #11 /healthz returns version ✓ #12 README notes other-repo#4 dashboard PR #13"Closes #11" → merged into main Closed Project “myapp roadmap” (belongs to a user/organization) Item = a reference to an issue / PR / draft issue Status Priority (single select) Iteration #11 · Done · P1 · Sprint 3 #12 · Todo · P2 · Sprint 3 PR #13 · Done (PR merged workflow) Views: Table · Board (columns by Status) · Roadmap (by date) Fields ≤ 50 · items ≤ 50,000
Figure 3-1: sub-issues form a tree; Project items are just references, field values are stored in the project, and the issue's own state is driven by PR closing keywords

Animation: automatic movement of an issue across the board

Click “Next” step by step. Each step shows the event that actually fires and the component that runs it (the Issues service, the built-in Projects workflows, and closing-keyword handling after a PR merge). Assumes the project has the “Item added → Todo” workflow and “Auto-add” enabled (both must be turned on manually), plus the two workflows enabled by default.

Todo
In Progress
Done
Click “Next” to start.
$

Core commands

CommandPurposeKey parameters
gh label create / list / cloneManage labels--color,--description,--force; gh label clone SRC/REPO Copy a full set of labels
gh api repos/{owner}/{repo}/milestones -f title=…Create milestones (gh has no milestone subcommand)-f due_on=2026-12-31T00:00:00Z
gh issue createCreate issue-t,-b,-l,-a @me,-m,--parent N,-p "project name"
gh issue editEdit--add-label,--add-sub-issue N,M,--remove-parent
gh issue listFilter list-l bug -a @me -s open --search "sort:updated-desc"
gh issue closeClose--reason completed|"not planned",-c "comment"
gh project create / item-add / field-create / item-listManage ProjectsRequires a token with the project scope: gh auth refresh -s project
gh repo edit --enable-discussionsEnable DiscussionsRequires Maintain or above
gh label create "area/api" --color 1d76db --description "Flask routes" --force
gh label create "priority/p1" --color b60205 --force
gh api repos/{owner}/{repo}/milestones -f title=v1.2.0 -f due_on=2026-12-31T00:00:00Z --jq '{number, title, due_on}'
✓ Label "area/api" created in your-login/myapp
✓ Label "priority/p1" created in your-login/myapp
{"due_on":"2026-12-31T08:00:00Z","number":1,"title":"v1.2.0"}

{owner}/{repo} is a gh placeholder that is automatically replaced with the repository in the current directory. due_on time of day may be normalized (08:00 in the example is a sample value after time-zone conversion).

# parent issue + sub-issues
PARENT=$(gh issue create -t "feature: expose version info" -b "Track version across API and docs" -m v1.2.0 | grep -o '[0-9]*$')
gh issue create -t "/healthz returns version" -b "Add version field" -l area/api --parent $PARENT
gh issue create -t "Document version endpoint" -b "README section" -l documentation --parent $PARENT
gh issue view $PARENT --json title,milestone --jq '{title, milestone: .milestone.title}'
https://github.com/your-login/myapp/issues/3
https://github.com/your-login/myapp/issues/4
{"milestone":"v1.2.0","title":"feature: expose version info"}
# Project: create, add fields, add items
gh auth refresh -s project
gh project create --owner @me --title "myapp roadmap" --format json --jq .number      # note the number, for example 1
gh project field-create 1 --owner @me --name Priority --data-type SINGLE_SELECT --single-select-options "P1,P2,P3"
gh project item-add 1 --owner @me --url https://github.com/$(gh api user --jq .login)/myapp/issues/3
gh project item-list 1 --owner @me --format json --jq '.items[] | {title: .title, status: .status}'
1
✓ Created field "Priority"
{"status":"","title":"feature: expose version info"}

Lab 3: set up a v1.2.0 plan for myapp (about 6 min)

Goal: labels + milestones + parent/child issues + board + automation. Environment: personal repository myapp (if you have an organization, you can use --owner myorg-lab to create the project).
Labels, milestones, parent/child issues: run the first two script sections on the “Commands” page. Open the parent issue on the web and confirm that the sub-issue list and progress appear at the bottom.
Set issue types (web): under a personal account, Settings → Planning → Issue types shows the default task / bug / feature; in the parent issue's right sidebar, set the type to Feature, and set both sub-issues to Task.
Create project and board view: run the Project script on the “Commands” page; on the web, open the project → New view → Board, with columns by Status; then create a Table view, grouped by Parent issue .
Enable automation: top-right of the project … → Workflows: confirm Item closed and Pull request merged are enabled; turn on Item added to project(set to Todo) and Auto-add to project(filter is:issue,pr is:open, choose the repository myapp).
Verify auto-add:
gh issue create -t "chore: verify auto-add" -b "should appear in project" -l documentation
gh project item-list 1 --owner @me --format json --jq '.items[] | "\(.status)\t\(.title)"'
Todo	chore: verify auto-add
	feature: expose version info
…
(Optional) Enable Discussions and convert an issue into a discussion:
gh repo edit --enable-discussions
gh repo view --json hasDiscussionsEnabled

On the web, open “chore: verify auto-add” → right side “Convert to discussion” → choose the Q&A category.

Case 1: moving from “label hell” to issue types + Project fields

Problem: One organization has 80+ labels in each repository (type:bug,Type/Bug,bug 🐛…), so cross-repository reports cannot be counted. Approach: Enable organization-level issue types (Bug / Feature / Task / Incident); change priority and estimates to Project single-select and number fields; keep only area/*; use a script gh issue list --label X --json number + gh issue edit to migrate in bulk. Limitation: Up to 25 issue types; old and new coexist during migration, which must be documented in CONTRIBUTING.

Case 2: PRs on the release branch did not close issues

Problem: The team uses release/* branches; after a fix PR was merged into the release branch, the issue stayed open and the weekly report was wrong. Root cause: Closing keywords only take effect when merged into the default branch. Approach: Merge back into main, which closes it automatically; or after the release merge, use Actions to call gh issue close; in the Project, drive Status from the PR state.

Case 3: an open-source project uses Discussions to triage support requests

Problem: 70% of issues were usage questions, and maintainers were overwhelmed. Approach: Enable Discussions (Q&A category); in .github/ISSUE_TEMPLATE/config.yml disable blank issues and add a contact link pointing to Discussions (Module 6); Triage volunteers convert mistakenly opened issues into discussions. Result: Issues now contain only reproducible bugs and features that have been agreed on in discussion.

Common errors and fixes

error: your authentication token is missing required scopes [project read:project]

Cause: The token that gh signs in with by default does not include the project scope.

gh auth refresh -s project
gh auth status
A PR with “Fixes #12” was merged, but the issue is still open

Cause: the PR was not merged into the default branch; the keyword was written in the title instead of the description or commit message (follow the official documentation); keyword syntax error (such as Fix: #12,#12 fixed); or the issue is in another repository but the cross-repository form was not written OWNER/REPO#12.

gh pr view 13 --json baseRefName,closingIssuesReferences --jq '{base: .baseRefName, closes: [.closingIssuesReferences[].number]}'

Fix:closes If it is empty, no link was established: add the keyword to the PR description, or link manually via Development in the PR sidebar.

could not add sub-issue: parent issue has reached the maximum number of sub-issues

Cause: Each parent issue can have at most 100 sub-issues, nested at most 8 levels.

Fix: Add an intermediate issue level (for example, grouping by module).

On the Project board the issue is closed but Status did not change to Done

Cause: The Item closed workflow is turned off, or the Done option of the Status field was renamed or deleted.

Fix: Project … → Workflows: check and turn it back on; confirm the workflow's target value still exists.

gh issue create: could not add label: 'area/api' not found

Cause: The label must already exist. Fix:gh label create "area/api", or use gh label clone to copy a full set of labels from a template repository.

Command-line questions
1. List the open issues assigned to you, with the bug label, sorted by most recently updated.
gh issue list -a @me -l bug -s open --search "sort:updated-desc"
2. Make the existing #7 and #8 sub-issues of #5.
gh issue edit 5 --add-sub-issue 7,8
Scenario analysis
The product manager wants: each sprint's board automatically collects all new bugs; after a fix PR is merged, the card automatically moves to Done; managers can view progress of all sub-tasks by “feature”. Please design the Project configuration.

(1) Fields: Status (Todo / In Progress / Done), Iteration (two weeks, including holidays), Priority (single select). (2) Workflows: Auto-add (repository myapp, filter is:issue is:open type:Bug, follow the UI prompts for the exact filter syntax), Item added → Todo, Pull request merged → Done, Item closed → Done (on by default). (3) Views: Board with columns by Status, filtered iteration:@current; Table view grouped by Parent issue and showing the Sub-issue progress field. (4) Convention: the fix PR description must include Fixes #N (written into the PR template, Module 6), and it must be merged into the default branch.

Verified instructional videos

▶
How to use GitHub issues and projects | GitHub for Beginners — GitHub
English · official channel · closely matches this module: issues, labels, Projects views
▶
Getting started with open source contributions for beginners — GitHub
English · official channel · good first issue, contributor perspective

Official documentation

Video storyboard script (about 90 seconds)

Shot 1 · 0–20s
Scene: three cards: Issue (checklist icon), Project (board), Discussion (speech bubble).
Narration: Issues record what to do, Projects show who is doing it and how far along, and Discussions cover things not yet decided.
Shot 2 · 20–45s
Scene: a parent feature issue expands into three sub-issues; the progress bar goes from 0/3 to 1/3.
Narration: use issue types to tell bugs, features and tasks apart; use sub-issues to split large work, up to 8 levels deep.
Shot 3 · 45–75s
Scene: a new issue flies automatically into the Todo column; the PR says Closes #11, and after merging the card slides to Done.
Narration: auto-add, Item added, PR merged: these built-in workflows make the board move by itself. Note: an issue is closed automatically only when the PR is merged into the default branch.
Shot 4 · 75–90s
Scene: a question issue is converted into a Q&A discussion and marked as the answer.
Narration: usage questions go to Discussions; Issues keep only the work that really needs doing.
or get a score of ≥ 70% in the quiz

Module 4 · Pull request end-to-end workflow

21:00 – 29:00 · push → check runs → review → ruleset evaluation → merge method: what the platform does at each step
8 minCore animationPrivate repository protection requires Pro/Team+★★★★★
Learning objectives
  • Walk through the PR lifecycle: draft → ready for review → review (comment / approve / request changes, suggested changes) → checks → ruleset evaluation → merge → delete branch → close issue.
  • Understand how required checks (“must succeed on the latest head SHA”), stale approvals and “branch must be up to date with the base branch” rules work, and be able to read mergeStateStatus.
  • Compare the effects of the three merge methods (merge commit / squash and merge / rebase and merge) on the commit graph, SHAs, signatures and later collaboration, and use auto-merge correctly.
Prerequisite knowledge:Git Lesson 2(merge and rebase principles, PR workflow),Git Lesson 3(ruleset and CODEOWNERS configuration). This module does not repeat these low-level topics. Importance:★★★★★

What: what a PR is (platform perspective)

A pull request is a proposal to “merge the head branch into the base branch”. GitHub organizes context around it: Conversation (description, timeline, review), Commits, Checks, Files changed, and a Findings tab that shows automated review results (such as code scanning); the merge box summarizes blockers. When a PR is opened, GitHub creates temporary refs: refs/pull/N/head (pointing to the head branch) and, when possible, the refs/pull/N/merge (simulated merge result); CI and integrations use them to evaluate the PR without changing the base branch.

Why: why all changes go through PRs

  • Review: a second pair of eyes and knowledge sharing; CODEOWNERS automatically brings in the right people.
  • Automated gates: required checks (tests, lint, security scans) run before merging.
  • Audit: who approved which change, when, and on the basis of which discussion.
  • Rulesets make the above mandatory, rather than a convention.

How: each stage of the lifecycle

StagePlatform behaviourKey points
Draft PRCI can run, but it cannot be merged, code owners are not automatically requested for reviewsuitable for sharing progress early; gh pr create --draft,gh pr ready switching to ready for review (code owners are requested at this point)
Request reviewThe requester needs Write; you can request individuals or teams who have Read on the repositoryLarge teams can enable automatic assignment (code review assignment) to avoid notifying everyone
ReviewThree outcomes: Comment, Approve, Request changes; anyone with Read can reviewOnly Write or above approvals / change requests count toward “required reviews”
Suggested changesinserts into a line comment a ```suggestion code block; the author can commit it with one click (individually or in batches)Applying suggestions requires Write; it creates a new commit → triggers a check re-run
Status checksActions or external CI writes results back via the Checks / Statuses APIRequired checks must succeed on the latest commit SHA ; success,skipped,neutral count as passing; a check and a status with the same name must both pass
Ruleset evaluationAggregates all applicable rulesets and branch protection,taking the strictestif not met, the merge button is greyed out and the reasons are listed
MergeRequires Write; merge using a method the repository allows (and the ruleset permits)You can tick the option to automatically delete the head branch after merging

Common rules (ruleset pull_request / status checks rules)

  • Require a pull request before merging: required number of approvals,dismiss old approvals when a new commit is pushed (dismiss stale approvals), require code owner approval, require that the “last push” be approved by someone other than the pusher, require all comment threads to be resolved, and restrict the allowed merge methods.
  • Require status checks to pass: list the required check names; optionally “require branches to be up to date before merging” (strict). When enabled, once base moves ahead you must first Update branch and then re-run the checks.
  • Block force pushes,Restrict deletions,Require linear history (disallow merge commits),Require signed commits,Require deployments to succeed,Require merge queue.
  • Rulesets and legacy branch protection can coexist, and all applicable rules take effect (rule layering). Availability: Free accounts can use it on public repositories; private repositories require Pro / Team / Enterprise; merge queues only apply to organization public repositories or GHEC private repositories.

Three merge methods

Create a merge commitSquash and mergeRebase and merge
Git equivalentgit merge --no-ffSquashes all of the PR's commits into one new commit and fast-forwards onto baseReplays each commit onto base one by one, then fast-forwards
Adds to basethe original commits (SHAs unchanged) + 1 merge commit1 new commitN new SHAs commits
History shapeNon-linear (preserves branch topology)Linear, one commit per PRLinear, keeps each commit
Author informationPreservedA single commit after squashing (Co-authored-by records multiple authors)Author preserved; GitHub always updates the committer and generates new SHAs
SignaturesOriginal commit signatures are kept; the merge commit is signed by GitHubGitHub signs the new commitReplayed commits have no signature verification (GitHub does not have your private key)
Special behaviour—Continuing to work on a branch that was squash-merged and opening another PR causes old commits to reappear and conflicts to recurDrops commits that were already empty (unlike local git rebase )
Suitable forNeeding full branch history, release branch mergesMost application repositories (one revertible commit per PR)Repositories with carefully curated commit granularity

In the repository's Settings → General → Pull Requests, you can enable only one method to enforce consistency; rulesets can also restrict the allowed methods. If the two conflict (for example, the repository disables rebase while the ruleset only allows rebase), the PR cannot be merged. When using a merge queue, the queue determines the merge method.

Auto-merge

  • First allow auto-merge in the repository settings; someone with Write can enable it for a PR (gh pr merge --auto --squash).
  • The enable option only appears when the PR cannot be merged for now (for example, waiting for required reviews or checks); once all conditions are met, it merges automatically using the chosen method.
  • When someone without write permission pushes new commits to the head branch or changes the base branch, auto-merge is disabled.

When: choosing and connecting

Team conventions are usually: Ruleset requires PR + 1 approval + required checks + resolved conversations + squash only, and the branch is deleted automatically after merging. For what merging and rebasing actually do at the Git level, see Git Lesson 2; for the configuration screens of each ruleset option and the CODEOWNERS syntax details, see Git Lesson 3.

Common misconceptions (1) “A PR author can approve their own PR”: no; in a single-person repository, either set the required approvals to 0 or give an admin bypass. (2) “Checks passed on the previous commit, so that's enough”: they must pass on the latest head SHA; pushing a new commit re-runs the checks. (3) “rebase and merge is identical to a local rebase”: GitHub always creates new SHAs, updates the committer, drops empty commits and removes signature verification. (4) “You can keep using the same branch after a squash”: this causes old commits to reappear in the new PR. (5) “Free private repositories can also enforce reviews”: protection rules on private repositories require Pro/Team/Enterprise.

Sequence diagram: the platform event flow of one PR

DeveloperGitHub repository/PRActions / CIReviewer / CODEOWNERSRuleset engine git push feat/version gh pr create (draft) Create refs/pull/N/head and /merge pull_request: opened check run lint: success @head SHA gh pr ready Request review from code owners (notification) review: Request changes + suggestion Apply suggestion = new commit synchronize → checks re-run; old approvals dismissed (if configured) review: Approve Evaluate: approval count, code owner, checks @ latest SHA, conversations, merge method, linear history CLEAN → merge allowed (or executed automatically by auto-merge)
Figure 4-1: each arrow is a webhook event or API call; any new commit (synchronize) restarts the checks and (optionally) approvals

How the three merge methods affect the commit graph

Create a merge commitSquash and mergeRebase and merge M (2 parents) F1 F2 F3 (SHAs unchanged)AB S (F1+F2+F3) original commits do not enter main F1' F2' F3' (new SHAs) git log --first-parent only shows MRevert: git revert -m 1 M One PR = one commit, easy to revertthe head branch should be deleted after merging Linear and keeps granularitycommitter becomes GitHub, signature verification is lost Blue = original commits on base · Orange = PR commits · Green = objects added to base after merging
Figure 4-2: final shape of the base branch for the three methods; the “Require linear history” rule forbids the one on the left

Core animation: the platform event flow of a PR from push to merge

After choosing a merge method and fault injection, click “Next”. The top is the event pipeline, the middle is the ruleset evaluation panel, and the bottom is the base branch commit graph and the terminal/event log. Mechanism basis: docs.github.com's Pull requests, Troubleshooting required status checks, About merge methods, and Automatically merging a pull request.

Ruleset evaluation (main)
base branch commit graph
Click “Next” to start.
$

Core commands

CommandPurposeKey parameters
gh pr createCreate PR--draft,--fill (fill title/body from commit messages),-B main,-r USER,ORG/TEAM,-l,-a @me,-T template,--dry-run
gh pr ready / gh pr ready --undoDraft ↔ ready for reviewRequest code owners when converting to ready
gh pr checkout NCheck out someone else's PR locallyactually fetches refs/pull/N/head
gh pr diff / gh pr view --commentsView before reviewing--name-only,--web
gh pr reviewSubmit review--approve,--request-changes -b,--comment -b
gh pr checksView checks--watch,--required,--fail-fast
gh pr update-branchMerge base (or --rebase) into headused when “require branches to be up to date” is on
gh pr mergeMerge-m/-s/-r,--auto,--disable-auto,-d (delete branch),--match-head-commit SHA,--admin (bypass requirements; requires permission)
gh pr view --json mergeStateStatus,mergeable,reviewDecisionWhy it cannot be mergedsee the reading guide below
git switch -c feat/version
sed -i 's/return jsonify(status="ok")/return jsonify(status="ok", version=os.getenv("APP_VERSION", "dev"))/' app.py
git commit -am "feat(api): report version in /healthz"
git push -u origin feat/version
gh pr create --draft --fill --body "Closes #4"
remote: Create a pull request for 'feat/version' on GitHub by visiting:
remote:      https://github.com/your-login/myapp/pull/new/feat/version
…
Creating draft pull request for feat/version into main in your-login/myapp

https://github.com/your-login/myapp/pull/6
gh pr view 6 --json isDraft,mergeStateStatus,mergeable,reviewDecision,statusCheckRollup \
  --jq '{isDraft, mergeStateStatus, mergeable, reviewDecision, checks: [.statusCheckRollup[] | {name, conclusion}]}'
{"checks":[{"conclusion":"SUCCESS","name":"lint"}],"isDraft":true,"mergeStateStatus":"DRAFT","mergeable":"MERGEABLE","reviewDecision":""}

How to read it:mergeable Answers “is there a conflict at the Git level?” (MERGEABLE / CONFLICTING / UNKNOWN; right after a push it is often briefly UNKNOWN); mergeStateStatus answers “can it be merged at the platform level?”: CLEAN mergeable,BLOCKED blocked by rules (missing approval or required checks),BEHIND branch needs updating,DIRTY has conflicts,UNSTABLE non-required check failed,DRAFT draft. reviewDecision: APPROVED / CHANGES_REQUESTED / REVIEW_REQUIRED, empty when no required reviews are configured.

# View PR refs on the server (ls-remote was covered in the Git course)
git ls-remote origin 'refs/pull/6/*'
9f3c2a1e0b7d4c5a8e6f1b2c3d4e5f6a7b8c9d0e	refs/pull/6/head
4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c	refs/pull/6/merge

How to write a suggested change

```suggestion
    return jsonify(status="ok", version=os.getenv("APP_VERSION", "0.0.0"))
```

In Files changed, select one or more lines and comment; clicking the “±” icon automatically inserts the code block above. The author clicks “Commit suggestion” in Conversation, or clicks “Add suggestion to batch” in Files changed and then commits several at once.

Lab 4: ruleset + draft PR + squash merge (about 8 min)

Goal: use the API to create a ruleset for main (PR, conversations resolved, required check lint, only squash/rebase allowed, force pushes and deletions blocked), then walk through one PR. Environment: public repository myapp (free private repositories cannot enforce rulesets).
Create the ruleset (for solo practice set the approval count to 0; with a partner change it to 1):
cat > /tmp/ruleset.json <<'EOF'
{
  "name": "protect-main",
  "target": "branch",
  "enforcement": "active",
  "conditions": { "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] } },
  "rules": [
    { "type": "deletion" },
    { "type": "non_fast_forward" },
    { "type": "pull_request", "parameters": {
        "required_approving_review_count": 0,
        "dismiss_stale_reviews_on_push": true,
        "require_code_owner_review": false,
        "require_last_push_approval": false,
        "required_review_thread_resolution": true,
        "allowed_merge_methods": ["squash", "rebase"] } },
    { "type": "required_status_checks", "parameters": {
        "strict_required_status_checks_policy": false,
        "required_status_checks": [ { "context": "lint" } ] } }
  ]
}
EOF
gh api repos/{owner}/{repo}/rulesets --input /tmp/ruleset.json --jq '{id, name, enforcement}'
{"enforcement":"active","id":4123456,"name":"protect-main"}
Verify that direct pushes are rejected:
git switch main && git commit --allow-empty -m "test: direct push" && git push
remote: error: GH013: Repository rule violations found for refs/heads/main.
remote: - Changes must be made through a pull request.
remote: - Required status check "lint" is expected.
 ! [remote rejected] main -> main (push declined due to repository rule violations)
git reset --hard origin/main      # discard this test commit
Draft PR: run the commands on the “Commands” page to create feat/version and the draft PR commands (Closes #4 replace with the number of “/healthz returns version” from Module 3), then:
gh pr checks --watch
gh pr merge --squash      # expected to fail: drafts cannot be merged
lint	pass	12s	https://github.com/your-login/myapp/actions/runs/…
X Pull request your-login/myapp#6 is still a draft
Review and suggested changes:
gh pr ready
# With a partner: the partner leaves one suggestion on app.py in Files changed, then gh pr review 6 --request-changes -b "use semver default"
# Solo: leave a suggestion yourself on the web in Files changed (an author can suggest to themselves) and Commit suggestion
git pull                          # pull back the new commit produced by “Apply suggestion”
gh pr checks --watch              # checks re-run on the new head SHA
(With a partner) approve: the partner runs gh pr review 6 --approve; you observe gh pr view 6 --json reviewDecision change to APPROVED. Push another commit and observe the approval being dismissed (dismiss stale) and then changing back to REVIEW_REQUIRED (when the approval count is 1).
Squash merge and observe the commit graph:
gh pr merge 6 --merge     # expected to fail: the ruleset only allows squash/rebase
gh pr merge 6 --squash --delete-branch
git switch main && git pull
git log --oneline --graph -5
gh issue view 4 --json state,stateReason --jq '{state, stateReason}'
✓ Squashed and merged pull request your-login/myapp#6 (feat(api): report version in /healthz)
✓ Deleted local branch feat/version and switched to branch main
✓ Deleted remote branch feat/version
* 7c1d2e3 (HEAD -> main, origin/main) feat(api): report version in /healthz (#6)
* 1a2b3c4 ci: add minimal lint workflow
* 0f9e8d7 feat: initial myapp
{"state":"CLOSED","stateReason":"COMPLETED"}

The squash commit title defaults to include (#6); the two commits in the PR (the original commit + the applied suggestion) are both absent from main.

(Optional) Try auto-merge: repository Settings → General → tick “Allow auto-merge”. After opening a new PR, immediately gh pr merge --auto --squash, and the PR will merge automatically once lint passes.

Case 1: main build fails after “green” PRs are merged

Problem: Two PRs each passed checks, but after being merged one after the other, main failed to compile: one changed a function signature and the other changed the call site. Root cause: The second PR's checks ran against the old base. Approach: Enable “Require branches to be up to date” (strict), or use the organization's public repository / GHEC private repository merge queue, which re-runs checks on the combination of “base + earlier PRs in the queue”. Cost: In strict mode, frequent Update branch operations increase CI cost; the merge queue needs additional merge_group event triggers (Lesson 2).

Case 2: conflict between the signed-commit requirement and rebase and merge

Problem: After enabling “Require signed commits”, all PRs the team merged with rebase and merge were rejected. Root cause: When GitHub replays commits it cannot sign them with your private key, so the replayed commits have no signature verification. Approach: Switch to squash or merge commit (GitHub signs with its own key), or rebase locally, sign, and push.

Case 3: a large team's review requests cause a notification storm

Problem: CODEOWNERS points to @org/engineering (120 people); every PR notifies everyone, and nobody actually reviews. Approach: CODEOWNERS points to small teams by directory; enable code review assignment in the team settings (round-robin assignment of 1–2 people); the ruleset requires code owner approval. See Git Lesson 3 the CODEOWNERS module.

Common errors and fixes

Merging is blocked: Required status check "lint" is expected.

Cause: The required check name does not match the actual check run name (for example a job was renamed, or the matrix job name is lint (3.13)), or the workflow did not run at all because of paths path filtering, or the check must have run successfully in that repository within the last 7 days before it can be selected as required.

gh pr checks 6
gh api repos/{owner}/{repo}/commits/$(gh pr view 6 --json headRefOid --jq .headRefOid)/check-runs --jq '.check_runs[].name'

Fix: Make the name in the rule match the actual check name; for workflows skipped by path filters, use a job that always runs and decides internally (Lesson 2).

X Pull request #6 is not mergeable: the base branch policy prohibits the merge.

Cause: The ruleset is not satisfied: approval missing, conversations unresolved, merge method not allowed, etc.

gh pr view 6 --json mergeStateStatus,reviewDecision
gh api repos/{owner}/{repo}/rules/branches/main --jq '.[].type'

Fix: Work through the reasons listed in the merge box one by one; rules/branches/main list all rules that apply to this branch (from all rulesets).

This branch has conflicts that must be resolved (mergeStateStatus: DIRTY)

Fix: Locally, run git fetch && git merge origin/main (or rebase), resolve the conflicts and push; simple conflicts can be resolved in the web editor. For how conflict resolution works, see Git Lesson 2.

Can not approve your own pull request

Cause: The author cannot approve their own PR. Fix: Ask a colleague with Write to review; in a single-person repository set required_approving_review_count to 0, or configure a bypass for yourself (not recommended for auditing).

The “Enable auto-merge” button does not appear

Cause: auto-merge is not allowed for the repository; or the PR can already be merged immediately (the option only appears when it cannot be merged immediately); or you do not have Write.

Command-line questions
1. Enable “automatically squash-merge and delete the branch once checks pass” for the PR of the current branch.
gh pr merge --auto --squash --delete-branch
2. Merge only if the PR head is still the commit you reviewed (to prevent a secret push after review).
SHA=$(gh pr view 6 --json headRefOid --jq .headRefOid)
gh pr merge 6 --squash --match-head-commit "$SHA"
Scenario analysis
The team requires: each PR leaves exactly one commit on main, commits must be signed, tests must pass on the latest main before merging, and authors cannot merge unreviewed changes themselves. How should the merge methods and rules be configured?

Enable only squash as the merge method (GitHub signs squash commits, which satisfies Require signed commits; rebase and merge loses signature verification). Ruleset: Require a pull request (1 approval, dismiss stale approvals, require approval of the most recent push), Require status checks (strict, or use a merge queue on an organization public repository or a GHEC private repository), Require signed commits, Require linear history, Block force pushes, Restrict deletions. Do not grant bypass, or grant it only to a few people for emergency procedures, with auditing.

Verified instructional videos

▶
How to create a pull request in 4 min | GitHub for Beginners — GitHub
English · official channel · about 4 min · creating a PR
▶
How to merge a pull request | Introduction to GitHub — GitHub
English · official channel · merging a PR and merge options
▶
How to add code to your repository | GitHub beginner tutorial — GitHub
English · official channel · branches, commits, preparing before pushing to a PR

Official documentation

Video storyboard script (about 120 seconds)

Shot 1 · 0–20s
Scene: a developer runs git push; a draft PR appears on GitHub, and on the server the two refs refs/pull/6/head and refs/pull/6/merge light up.
Narration: when a PR is opened, GitHub creates temporary refs for it; CI tests against the simulated merge result and does not change main.
Shot 2 · 20–45s
Scene: Actions runs lint, and a green check is attached to the head commit; the author clicks Ready for review, and code owners receive notifications.
Narration: check results are bound to the commit SHA; code owners are requested only when a draft is turned into ready for review.
Shot 3 · 45–75s
Scene: a reviewer leaves a suggestion, the author commits it with one click, a new commit appears, and the old green check and approval both turn grey.
Narration: any new commit re-runs the checks; if dismiss-stale approvals is enabled, the review must also be redone.
Shot 4 · 75–100s
Scene: the ruleset panel ticks items one by one: approval, checks, conversations, merge method; the status changes from BLOCKED to CLEAN.
Narration: the ruleset takes the strictest set among all applicable rules, and only lets the PR through when all are satisfied.
Shot 5 · 100–120s
Scene: three commit graphs side by side: the merge commit forks, squash has a single new point, and rebase has points with three new SHAs.
Narration: three merge methods, three history shapes. Choosing one is choosing how the team reads and reverts history.
or get a score of ≥ 70% in the quiz

Module 5 · gh CLI and REST / GraphQL API

29:00 – 37:00 · gh is a friendly shell over the API; gh api is the universal key to the entire API
8 mingh 2.104.0REST version 2026-03-10★★★★★
Learning objectives
  • Understand gh authentication and configuration (credential store,GH_TOKEN,GH_HOST, multiple accounts), and use fluently gh repo,gh issue,gh pr,gh run and --json/--jq output.
  • Use gh api to call REST (placeholders,-f/-F,--method,--paginate/--slurp) and GraphQL (variables,$endCursor pagination).
  • Know the criteria for choosing between REST and GraphQL, the API version header, and the values and handling of primary and secondary rate limits.
Prerequisite knowledge: Modules 0–4; ability to read JSON. Importance:★★★★★ (the automation in Lessons 2–7 is all built on it)

What: what gh is

GitHub CLI (gh) is GitHub's official open-source command-line tool (written in Go, repository cli/cli). It wraps common platform operations as commands: repositories, issues, PRs, Actions runs, releases, gists, Projects, codespaces, secrets, and so on. Internally it calls GitHub's REST API and GraphQL API; when there is no ready-made command,gh api can call any endpoint directly with your authentication.

Why: why use gh instead of curl

  • Authentication: automatically attaches the token (from the credential store), supports multiple hosts (github.com, GHE.com, GHES) and multiple accounts (gh auth switch).
  • Context: automatically detects OWNER/REPO in a repository directory,{owner}/{repo}/{branch} and placeholders are replaced automatically.
  • Output: --json fields + built-in --jq (no need to install jq) + --template (Go templates).
  • Pagination: --paginate automatically follows REST's Link header or GraphQL's pageInfo.
  • CI-friendly: set in Actions GH_TOKEN: ${{ github.token }} to use it (Lesson 2).

How: authentication model

MethodSuitable forNotes
gh auth login (browser device code)Developer's local machineThe OAuth token is stored in the system credential store; the default scopes include repo,read:org,gist, and when needed use gh auth refresh -s scope to add (for example project,workflow,admin:org)
gh auth login --with-token < token.txtNo-browser environmentOfficial documentation: pass a classic PAT, minimum scopes repo,read:org,gist
environment variable GH_TOKEN (or GITHUB_TOKEN)scripts, CI; fine-grained PATs are recommended with this methodtakes priority over stored credentials; for GHE hosts use GH_ENTERPRISE_TOKEN
--expiringwants tokens to expire and refresh automaticallyA newer gh preference option; whether it is issued depends on the host and OAuth app; Git ≥ 2.46 is recommended

How: REST vs GraphQL

REST (api.github.com)GraphQL (api.github.com/graphql)
ModelResources + HTTP verbs; each endpoint returns a fixed structureA single endpoint; the client precisely declares the fields and relations it needs
Suitable forSimple CRUD, Actions, rulesets, webhooks and other features offered only by RESTFetching multiple levels of related data at once (PR + reviews + checks + linked issues), Projects (the newer Projects API is GraphQL)
Paginationper_page (usually a maximum of 100) + Link: <…>; rel="next"cursor: first: 100, after: $endCursor + pageInfo { hasNextPage endCursor }
VersionX-GitHub-Api-Version header; latest 2026-03-10, default when no header is sent: 2022-11-28; older versions are supported for at least 24 months after a new version is releasedNo versioning; evolves by schema changes and deprecation notices
Primary rate limitUnauthenticated 60 requests/hour (per IP); authenticated users 5,000 requests/hour; in Actions GITHUB_TOKEN 1,000 requests/hour per repository (GHEC resources 15,000); GitHub Apps on GHEC organizations 15,000 requests/hourMeasured by points: users 5,000 points/hour; App installations on GHEC organizations 10,000 points/hour; GITHUB_TOKEN 1,000 points/hour per repository

Secondary rate limits (shared by both APIs): at most 100 concurrent requests; per minute, REST 900 points and GraphQL 2,000 points (REST GET/HEAD/OPTIONS count 1 point, most POST/PATCH/PUT/DELETE count 5 points; GraphQL queries count 1 point, mutations 5 points); generally no more than 80 content-creating requests per minute and 500 per hour. Exceeding the limit returns 403 or 429, and the response may include retry-after, otherwise wait x-ratelimit-reset.

When: a selection guide

  • A ready-made gh subcommand exists → use the subcommand (stable output, interactive-friendly); in scripts add --json.
  • No subcommand (milestones, rulesets, teams, permission queries…) → gh api use REST.
  • Need to fetch a lot of related data at once or operate on Projects → gh api graphql use GraphQL.
  • Long-running services or organization-level automation → GitHub App (higher limits, fine-grained, not dependent on a personal account; Lessons 5 and 7).
Common misconceptions (1) “gh is just a shortcut to the web”: it is a complete API client,gh api and can do anything the API can do. (2) “GraphQL has no rate limit”: it is charged by points, and nested connections are expensive. (3) “--paginate returns one JSON array”: by default it outputs multiple JSON pages one after another; to merge them into one array add --slurp (or in --jq process page by page). (4) “Writing the PAT into the script is more convenient”: use GH_TOKEN environment variables or secrets, and never commit tokens (push protection blocks common token formats; Lesson 6).

Architecture diagram: gh's request path

Your terminal gh pr list / gh api … git remote → OWNER/REPO GH_TOKEN or credential store ~/.config/gh/hosts.ymlconfig.yml (aliases, protocol) REST api.github.comGET /repos/{o}/{r}/issues?per_page=100Link: rel="next" → next page GraphQL POST /graphqlquery($endCursor: String) {…}pageInfo { hasNextPage endCursor } Response headers x-ratelimit-limit: 5000x-ratelimit-remaining: 4987x-ratelimit-used: 13x-ratelimit-reset: 1763215200x-ratelimit-resource: core | graphqlx-github-api-version-selectedx-github-request-id (provide when reporting a problem) GH_DEBUG=api gh pr list can print the HTTP requests and response headers that gh actually sends
Figure 5-1: gh infers the repository from the git remote, takes the token from GH_TOKEN or the credential store, then chooses REST or GraphQL depending on the command

gh command map

gh auth · config · alias repo · browse issue · label · project pr · search run · workflow · cache secret · variable release · attestation api (universal) · extension
Figure 5-2: this lesson uses the top row and api; run/workflow/secret are in Lesson 2, release/attestation in Lesson 5

Translator: what HTTP request does this gh command actually send?

Click a command to step through the request, response headers and pagination. The request content is an illustration compiled from gh's implementation and the API documentation; on your machine, run the same command with GH_DEBUG=api prefix to see the real request.

Request
Response (excerpt)
Select a command.
Remaining quota this hour (illustrative):core 5000 · graphql 5000

gh subcommand overview

CommandPurposeCommon parameters
gh auth login / status / switch / refresh / token / logoutAuthentication management--hostname,-s scope,gh auth token print the current token (be careful not to leak it)
gh repo create / clone / view / list / fork / edit / syncRepositories--template,--source . --push,--json,gh repo fork --clone
gh issue list / create / view / edit / close / developissuegh issue develop N --checkout create a linked branch
gh pr create / list / view / checkout / review / merge / checksPRs (Module 4)--json,--web
gh run list / view / watch / rerun / downloadActions runsgh run view --log-failed,gh run rerun --failed
gh search repos / issues / prs / codesearch (Module 7)--owner,--language,--json
gh alias set / gh extension installextensions for ghgh alias set prs 'pr list --author @me'
gh api ENDPOINTany API-X/--method,-f k=v (string),-F k=v (automatic type: numbers, true/false, null,@file),-H,--input,--paginate,--slurp,--jq,-t,-i (show response headers)

--json and --jq

gh pr list --state merged -L 5 --json number,title,mergedAt,author \
  --jq '.[] | "#\(.number)\t\(.author.login)\t\(.mergedAt[:10])\t\(.title)"'
#6	your-login	2026-11-15	feat(api): report version in /healthz

REST: placeholders, parameters and pagination

# GET (defaults to POST when -f/-F is used; explicitly use --method GET when you need GET query parameters)
gh api repos/{owner}/{repo}/issues --method GET -f state=all -F per_page=100 --paginate --jq '.[] | select(.pull_request | not) | .number' | wc -l

# merge all pages into one array, then count
gh api 'repos/{owner}/{repo}/issues?state=all&per_page=100' --paginate --slurp --jq 'add | length'

# show response headers (check Link and rate limits)
gh api -i 'repos/cli/cli/issues?per_page=2' | grep -iE '^(link|x-ratelimit)'

# specify the REST API version
gh api -H "X-GitHub-Api-Version: 2026-03-10" repos/{owner}/{repo} --jq .full_name
4
6
Link: <https://api.github.com/repositories/212613049/issues?per_page=2&page=2>; rel="next", <https://api.github.com/repositories/212613049/issues?per_page=2&page=…>; rel="last"
X-Ratelimit-Limit: 5000
X-Ratelimit-Remaining: 4991
X-Ratelimit-Reset: 1763215200
X-Ratelimit-Resource: core
X-Ratelimit-Used: 9
your-login/myapp

Note: The REST issues list includes PRs (a PR is also an issue in the data model); use select(.pull_request | not) to exclude them. The 4 printed by the first command is an example of the number of issues created so far in this lesson.

GraphQL: variables and cursor pagination

gh api graphql -F owner='{owner}' -F name='{repo}' -f query='
  query($owner: String!, $name: String!) {
    repository(owner: $owner, name: $name) {
      pullRequests(last: 3, states: MERGED) {
        nodes { number title mergedBy { login } reviews(first: 5) { totalCount }
                closingIssuesReferences(first: 5) { nodes { number } } }
      }
    }
    rateLimit { cost remaining resetAt }
  }' --jq '.data'
{"rateLimit":{"cost":1,"remaining":4993,"resetAt":"2026-11-15T15:00:00Z"},"repository":{"pullRequests":{"nodes":[{"closingIssuesReferences":{"nodes":[{"number":4}]},"mergedBy":{"login":"your-login"},"number":6,"reviews":{"totalCount":0},"title":"feat(api): report version in /healthz"}]}}}
# automatic pagination: the query must declare $endCursor and return pageInfo
gh api graphql --paginate --slurp -f query='
  query($endCursor: String) {
    viewer { repositories(first: 100, after: $endCursor) {
      nodes { nameWithOwner }
      pageInfo { hasNextPage endCursor } } }
  }' --jq '[.[].data.viewer.repositories.nodes[].nameWithOwner] | length'

Rate limits

gh api rate_limit --jq '.resources | {core: .core.remaining, graphql: .graphql.remaining, search: .search.remaining, code_search: .code_search.remaining}'
{"code_search":10,"core":4987,"graphql":4993,"search":30}

Querying /rate_limit itself does not consume the primary rate limit. The search API has its own lower per-minute limits (as above search and code_search).

Lab 5: answer one question with REST and one with GraphQL (about 6 min)

Goal: Question A: “Who merged myapp's recently merged PRs, with which method, and which issues did they close?”; Question B: “Which 3 of all my repositories have the most open issues?”
Observe gh's real requests:
GH_DEBUG=api gh pr list -L 1 2>&1 | grep -E '^\* Request|POST|GET|graphql' | head -5

You will see pr list sent POST https://api.github.com/graphql.

Question A (REST):
PR=$(gh pr list --state merged -L 1 --json number --jq '.[0].number')
gh api repos/{owner}/{repo}/pulls/$PR --jq '{number, merged, merged_by: .merged_by.login, merge_commit_sha: .merge_commit_sha[:7], base: .base.ref}'
gh api repos/{owner}/{repo}/commits/$(gh api repos/{owner}/{repo}/pulls/$PR --jq .merge_commit_sha) --jq '{parents: (.parents | length), committer: .commit.committer.name, verified: .commit.verification.verified}'
{"base":"main","merge_commit_sha":"7c1d2e3","merged":true,"merged_by":"your-login","number":6}
{"committer":"GitHub","parents":1,"verified":true}

One parent commit + committer is GitHub + verified signature → this is a commit produced by squash (or rebase); a merge commit would have 2 parent commits.

Question A (GraphQL, fetch everything at once): run the GraphQL query on the “Commands” page and confirm that closingIssuesReferences includes the issue from Module 3.
Question B (pagination + sorting):
gh api user/repos --method GET -f affiliation=owner -F per_page=100 --paginate --slurp \
  --jq 'add | sort_by(-.open_issues_count) | .[:3] | .[] | "\(.open_issues_count)\t\(.full_name)"'

REST's open_issues_count also counts open PRs.

Write an alias:
gh alias set mine 'issue list --assignee @me --state open'
gh alias set pv 'pr view --json number,title,mergeStateStatus,reviewDecision'
gh mine && gh alias list

Case 1: nightly report script triggers secondary rate limits

Problem: A script used 20 parallel processes to walk the PRs of 600 repositories and frequently received 403 You have exceeded a secondary rate limit. Approach: Switched to a single serial process; used one GraphQL query to fetch PRs + reviews + checks to reduce request count; on 403/429, read retry-after, and if absent, wait x-ratelimit-reset with exponential backoff; used a GitHub App installation token (GHEC 15,000 requests/hour) instead of a personal PAT. Limitation: GraphQL nested connections are charged by node count, so first use rateLimit { cost } to estimate query cost.

Case 2: gh reports “gh auth login required” in CI

Problem: Calling gh pr comment in a workflow fails. Root cause: There is no sign-in session on the runner. Approach: Set env: GH_TOKEN: ${{ github.token }} in the step, and in the workflow's permissions grant pull-requests: write (Lesson 2).

Case 3: use gh api to govern 200 repositories in bulk

Problem: The platform team wants to enable “delete branch after merge” for all organization repositories and allow only squash. Approach: gh repo list ORG -L 1000 --json name --jq '.[].name' | while read r; do gh api -X PATCH repos/ORG/$r -F delete_branch_on_merge=true -F allow_merge_commit=false -F allow_rebase_merge=false -F allow_squash_merge=true --silent; done. Limitation: First run a --dry-run style printout of the repositories to be changed; PATCH on archived repositories fails; a better long-term option is organization-level rulesets (Lesson 6).

Common errors and fixes

To get started with GitHub CLI, please run: gh auth login

Cause: Not signed in; or in CI / a container with neither a credential store nor GH_TOKEN.

gh auth status
echo "${GH_TOKEN:+GH_TOKEN is set}"
HTTP 401: Bad credentials (https://api.github.com/user)

Cause: The token expired or was revoked; an old GH_TOKEN/GITHUB_TOKEN is left in the environment (it takes priority over stored sign-in).

env | grep -E '^(GH_|GITHUB_)TOKEN' | cut -c1-20
unset GH_TOKEN GITHUB_TOKEN; gh auth status
gh: Not Found (HTTP 404) —— when calling gh api repos/{owner}/{repo}/...

Cause: Not inside a repository directory, so the placeholders cannot be resolved; endpoint misspelled; no permission on the private resource.

Fix: Enter the repository directory or use -R OWNER/REPO / and write out the full path; confirm the endpoint in the REST documentation.

gh: Validation Failed (HTTP 422) / "is not a valid value"

Cause: Wrong parameter type: using -f to pass a number or boolean (it becomes the string "true"), or nested JSON was passed with -f.

Fix: Use this for numbers/booleans: -F; for complex JSON use --input file.json; for arrays use -f 'labels[]=bug'.

API rate limit exceeded for user ID 1234567 / You have exceeded a secondary rate limit
gh api rate_limit --jq '.resources.core | {remaining, reset: (.reset | todate)}'

Fix: Wait for the reset; reduce concurrency; switch to GraphQL to fetch in bulk; use conditional requests (If-None-Match, 304 responses do not count toward the primary limit); use a GitHub App long term. (Deeper coverage in Lesson 7)

Command-line questions
1. Use one gh api command to output the titles of all open issues in the current repository (excluding PRs) as plain text, with automatic pagination.
gh api 'repos/{owner}/{repo}/issues?state=open&per_page=100' --paginate --jq '.[] | select(.pull_request | not) | .title'
2. Use GraphQL to query your own login name and the point cost of the current query.
gh api graphql -f query='{ viewer { login } rateLimit { cost remaining } }' --jq '.data'
Scenario analysis
You want to build a dashboard service that runs every 15 minutes and shows the open PRs, review status and required check status for an organization's 300 repositories. Querying repository by repository with a PAT + REST gets rate-limited quickly. How would you redesign it?

(1) Identity: register a GitHub App owned by the organization and use installation tokens (fine-grained, read-only permissions; 15,000 requests/hour / 10,000 GraphQL points/hour under GHEC), not dependent on a personal account. (2) Queries: use GraphQL to search(query: "org:ORG is:pr is:open", type: ISSUE, first: 100) fetch PRs + reviewDecision + statusCheckRollup,$endCursor in one request, paginate, and read rateLimit { cost } to control cost. (3) Incremental updates: subscribe to pull_request,pull_request_review,check_suite webhooks to update the cache in real time, and reduce scheduled full reconciliation to once per hour. (4) Protection: serialize requests, respect retry-after and x-ratelimit-reset, and use exponential backoff.

Verified instructional videos

▶
#GitHub #CLI - Crash Course — DevInsideYou
English · community channel · basics of gh authentication, repositories, issues and PRs (recorded earlier; for parameters follow this lesson and the official manual)

Official documentation

Video storyboard script (about 100 seconds)

Shot 1 · 0–20s
Scene: terminal input gh auth login; the browser pops up a device code page, and a token key flies into the system keychain.
Narration: gh signs in with a browser device code, and the token is stored in the system credential store. In scripts and CI, use the GH_TOKEN environment variable.
Shot 2 · 20–50s
Scene: gh pr list is split open and becomes a single POST /graphql request; gh api repos/.../issues becomes a GET request, and the Link rel=next in the response headers is highlighted.
Narration: behind gh's subcommands are REST and GraphQL. When there is no subcommand, gh api can call any endpoint.
Shot 3 · 50–80s
Scene: three pages of results are combined into one array by --slurp, and --jq filters out the titles.
Narration: --paginate turns pages automatically, --slurp merges all pages, and --jq has jq filtering built in, so nothing extra needs installing.
Shot 4 · 80–100s
Scene: the rate gauge drops from 5000 to 4987; when there are too many concurrent requests, a red secondary rate limit appears.
Narration: authenticated users get 5000 requests per hour, plus secondary limits on concurrency and points per minute. Serial requests, batching and backoff are the three disciplines of API automation.
or get a score of ≥ 70% in the quiz

Module 6 · Markdown, templates and repository community files

37:00 – 43:00 · put “how to take part in this project” into the repository: README, issue forms, PR templates, CONTRIBUTING, SECURITY, CODEOWNERS
6 minGFM · MermaidIssue forms are in public preview★★★★☆
Learning objectives
  • Use GitHub Flavored Markdown fluently: tables, task lists, alert blocks, auto-linked references, collapsible blocks, footnotes, Mermaid diagrams.
  • Write issue templates and issue forms (YAML),config.yml, PR templates, and CONTRIBUTING, CODE_OF_CONDUCT, SECURITY.md, SUPPORT, CODEOWNERS.
  • Master file locations and priority: the repository's .github/ → root directory → docs/; the public .github repository of the organization or personal account provides default files; which files cannot be provided by the default repository.
Prerequisite knowledge: Modules 3 and 4. Importance:★★★★☆

What: GitHub Flavored Markdown (GFM)

SyntaxWritten asUse
Task list- [ ] write tests / - [x] donePR self-check lists, small steps in an issue (use sub-issues for large work)
Table| Column | Column | + | --- | :---: |Comparisons, parameter descriptions
Alert blocks> [!NOTE],[!TIP],[!IMPORTANT],[!WARNING],[!CAUTION]Highlighting key information in the README
Auto-linked references#12,OWNER/REPO#12, commit SHAs,@user,@org/teamcross-referencing and notifying in issues/PRs/comments
Collapsible block<details><summary>Log</summary> … </details>Long logs, optional information
Code blocks```python; ```diff; in PR comments, ```suggestionsyntax highlighting and suggested changes
Diagrams```mermaid (flowcharts, sequence diagrams, pie charts, etc.), and geojson,topojson,stlrendering in issues, discussions, PRs, wikis and Markdown files
Math$E=mc^2$,$$ … $$formulas
PermalinksWhile browsing a file, press y to expand the URL into the canonical form with the commit SHAReference specific lines of a given version in an issue

Mermaid rendering uses the Mermaid version built into GitHub; in a ```mermaid block, write info to view the current version and confirm whether the new syntax is supported.

Community files at a glance

FilePurposeLocationCan be defaulted by the .github repository?
README.mdProject home page.github/, root directory,docs/ (uses the first one found, in this order)No (but .github repository's profile/README.md is shown on the organization profile)
CONTRIBUTING.mdHow to contribute; a link is shown when opening an issue or PRSame three locations as aboveYes
CODE_OF_CONDUCT.mdCommunity code of conductSame as aboveYes
SECURITY.mdHow to report vulnerabilities (used together with private vulnerability reporting and security advisories)Same as aboveYes
SUPPORT.mdWhere to get helpSame as aboveYes
FUNDING.ymlShows the Sponsor button.github/Yes
Issue templates / forms + config.ymlStructured issues.github/ISSUE_TEMPLATE/Yes (but as soon as a repository has its own valid templates or config, the default all are no longer used)
PR templateDefault content of the PR descriptionpull_request_template.md Placed in the root directory,docs/ or .github/; multiple templates go in .github/PULL_REQUEST_TEMPLATE/ and are chosen by adding ?template=name.md to the URLYes
Discussion category formsTemplates for new discussions.github/DISCUSSION_TEMPLATE/Yes
CODEOWNERSAutomatically requests review; used together with “require code owner approval”.github/, root directory,docs/ (uses the first one found, in this order)No: must be in each repository, and on the PR's base branch.
LICENSELicenseRoot directoryNo: must travel with the code when it is cloned, packaged or downloaded

How: organization-level default files

  • Under the organization (or personal account), create a repository named .github as a public repository, and put the files that can be defaulted into it.
  • Any repository under the account that does not have a file of the same kind (whether public or private) will use and display the default file; the lookup order inside the repository is .github/ → root → docs/, and only if none is found, use the .github repository's files (same order).
  • Default files do not appear in each repository's file list or Git history, and are not cloned. Change it in one place and it takes effect across the whole organization.

Issue forms vs Markdown templates

Markdown template (*.md)Issue form (*.yml, public preview)
ExperiencePre-filled text; submitters can delete all of itWeb form: input boxes, text areas, dropdowns, checkboxes; can be set as required
ResultUsed as-is as the issue bodyEach field's answer is converted to Markdown and written into the body
Metadatafront matter: name,about,title,labels,assigneesTop level: name,description,title,labels,assignees,projects,body is an array of fields
Applies toIssues and PRs (PRs only have Markdown templates)Issues only (PRs do not support forms)

CODEOWNERS essentials (connects with Git Lesson 3)

  • Syntax is similar to .gitignore, but does not support ! negation,[ ] character ranges,\# escaping; the last matching rule takes effect; multiple owners for the same pattern must be written on the same line.
  • Owners (users or teams) must have explicit Write on the repository; the team must be visible. Paths are case-sensitive; the file must be under 3 MB; invalid lines are skipped and highlighted on the web.
  • PRs use base branch's CODEOWNERS; draft PRs do not automatically request code owners.

When: the minimum usable set

Any team repository should have at least: README (what it is, how to run it, how to test it), CONTRIBUTING (branch and commit conventions, PR process), a PR template (linked issue, test notes, checklist), two issue forms for bug and feature + config.yml, CODEOWNERS, SECURITY.md; public repositories also add LICENSE and CODE_OF_CONDUCT. Public repositories can check their completion under Insights → Community standards.

Common misconceptions (1) “Putting .github CODEOWNERS in the repository governs all repositories”: no, CODEOWNERS is not a default-capable community file. (2) “A private .github repository can also provide default files”: it must be a public repository. (3) “Adding CODEOWNERS on a feature branch makes this PR request reviews”: the version on the base branch is used, so it must be merged into main first. (4) “Issue forms can be used for PRs”: PRs only support Markdown templates. (5) “Writing !docs/ can exclude”: negation is not supported; override it with a more specific rule placed later.

File lookup order

Repository myorg-lab/myappPublic repository myorg-lab/.github ① .github/CONTRIBUTING.md ? (2) Root directoryCONTRIBUTING.md ? ③ docs/CONTRIBUTING.md ? (4) Default files (same (1) → (2) → (3) order)Only default-capable file types Stop at the first match · look at organization defaults only if none exist Default-capableCONTRIBUTING · CODE_OF_CONDUCT · SECURITYSUPPORT · FUNDING.yml · ISSUE_TEMPLATEPR templates · Discussion forms · ACCESSIBILITY Not default-capableCODEOWNERS (version on the base branch)LICENSE (must travel with the code)README (profile/README.md is only for the organization home page) Special rule for ISSUE_TEMPLATERepository has its own valid templates or config.yml→ all ISSUE_TEMPLATE files in the default repository are not used(wholesale replacement, not merged file by file)
Figure 6-1: the three locations inside the repository take precedence, followed by the public .github repository of the organization or personal account

Issue forms from YAML to issue body

bug.ymlname: Bug reportlabels: [bug]body:- type: input (version, required)- type: textarea (logs, render: shell)- type: checkboxes (searched for duplicates) Web formVersion * [ 1.2.0 ]Logs [ multiline text ]☑ I have searched for duplicate issues *[ Create ] cannot submit while required fields are empty Issue body (Markdown)### Version1.2.0### Logs```shell … ```- [X] I have searched for duplicate issuesLabel bug added automatically
Figure 6-2: forms only change the “input experience”; what is ultimately stored is still a plain Markdown body

Resolution simulator: which file will GitHub ultimately use?

Select a file type and tick the locations where it exists; the simulator gives, following the official rules, the file GitHub actually uses and the reason.

Repository myorg-lab/myapp (main branch) myorg-lab/.github repository

File templates

Issue form: .github/ISSUE_TEMPLATE/bug.yml

name: Bug report
description: Report something that is broken in myapp
title: "[Bug]: "
labels: ["bug"]
body:
  - type: markdown
    attributes:
      value: "Thanks for taking the time to report a bug! Usage questions go to Discussions."
  - type: input
    id: version
    attributes:
      label: Version
      description: Output of `curl -s localhost:8000/healthz`
      placeholder: '{"status":"ok","version":"1.2.0"}'
    validations:
      required: true
  - type: dropdown
    id: runtime
    attributes:
      label: How do you run myapp?
      options: ["docker compose", "kubernetes", "bare python"]
    validations:
      required: true
  - type: textarea
    id: logs
    attributes:
      label: Relevant logs
      render: shell
  - type: checkboxes
    id: terms
    attributes:
      label: Checks
      options:
        - label: I searched existing issues and this is not a duplicate
          required: true

.github/ISSUE_TEMPLATE/config.yml

blank_issues_enabled: false
contact_links:
  - name: Questions and help
    url: https://github.com/your-login/myapp/discussions/categories/q-a
    about: Ask usage questions in Discussions, not in Issues.
  - name: Report a security vulnerability
    url: https://github.com/your-login/myapp/security/advisories/new
    about: Please report vulnerabilities privately.

PR template: .github/pull_request_template.md

## What and why
<!-- One paragraph. Link the issue: "Closes #123" (only closes when merged into the default branch) -->
Closes #

## How was this tested?
- [ ] `python -m py_compile app.py`
- [ ] `docker compose up` and `curl localhost:8000/healthz`

## Checklist
- [ ] Small, focused change (< 400 lines)
- [ ] Docs/README updated if behaviour changed
- [ ] No secrets, tokens or credentials in the diff

CODEOWNERS: .github/CODEOWNERS

# The last matching rule takes effect: general rules go first, specific rules go last
*                     @your-login
/.github/             @your-login
/.github/workflows/   @myorg-lab/platform
*.py                  @myorg-lab/backend
/docs/                @myorg-lab/docs-team @your-login

SECURITY.md

# Security Policy

## Supported versions
| Version | Supported |
| ------- | --------- |
| 1.2.x   | ✅        |
| < 1.2   | ❌        |

## Reporting a vulnerability
Please **do not** open a public issue. Use "Report a vulnerability" on the
Security tab (private vulnerability reporting). We reply within 3 business days.

Alert blocks and Mermaid in the README

> [!WARNING]
> `main` is protected. All changes go through pull requests.

```mermaid
flowchart LR
  user((User)) --> web[myapp / gunicorn :8000]
  web --> redis[(Redis)]
  web -. /healthz .-> probe[Health check]
```

Related commands

gh api repos/{owner}/{repo}/community/profile --jq '{health_percentage, files: (.files | map_values(. != null))}'
gh api repos/{owner}/{repo}/codeowners/errors --jq '.errors'
gh issue create --template "Bug report"            # use the specified template (interactive)
gh pr create --template pull_request_template.md
{"files":{"code_of_conduct":false,"code_of_conduct_file":false,"contributing":true,"issue_template":true,"license":false,"pull_request_template":true,"readme":true},"health_percentage":71}
[]

community/profile only meaningful for public repositories; codeowners/errors an empty array means all CODEOWNERS syntax is valid.

Lab 6: complete the community files for myapp (about 6 min)

Goal: through one PR (main is already protected), add issue forms, config.yml, a PR template, CODEOWNERS, CONTRIBUTING and SECURITY, and add alert blocks and Mermaid to the README.
Create a branch and write the files:
git switch main && git pull && git switch -c docs/community-files
mkdir -p .github/ISSUE_TEMPLATE
# Write bug.yml, config.yml, pull_request_template.md, CODEOWNERS and SECURITY.md from the “Commands” page into their corresponding paths, in turn
# In CODEOWNERS keep only yourself (a personal repository has no teams):
printf '*  @%s\n' "$(gh api user --jq .login)" > .github/CODEOWNERS
printf '# Contributing\n\n1. Open or pick an issue.\n2. Branch from main: `gh issue develop N --checkout`.\n3. Open a draft PR with `Closes #N`.\n4. Squash merge after review and green checks.\n' > CONTRIBUTING.md
Add alert blocks and Mermaid to the README: append the README snippet from the “Commands” page to README.md.
Commit and open a PR:
git add -A && git commit -m "docs: add community health files and templates"
git push -u origin docs/community-files
gh pr create --fill
gh pr view --web          # preview the README rendering in Files changed (Mermaid, alert blocks)

Note: this PR will not automatically request a code owner. CODEOWNERS is not yet on the base branch; only PRs opened after merging will do so.

Merge and verify:
gh pr checks --watch && gh pr merge --squash --delete-branch
gh api repos/{owner}/{repo}/codeowners/errors --jq '.errors | length'
gh api repos/{owner}/{repo}/community/profile --jq .health_percentage

Open https://github.com/your-account/myapp/issues/new/choose: you should see the “Bug report” form and two contact links, and no “Open a blank issue”.

(Optional, organization) default files: create a public repository myorg-lab/.github named .github, and put CODE_OF_CONDUCT.md and profile/README.md into it, then observe myorg-lab/myapp the Code of conduct link and the organization home page.
gh repo create myorg-lab/.github --public --add-readme
gh repo clone myorg-lab/.github /tmp/orgdotgithub && cd /tmp/orgdotgithub
mkdir -p profile && echo "# myorg-lab — practice org for the GitHub course" > profile/README.md
printf '# Code of Conduct\n\nBe kind. Report issues to the maintainers.\n' > CODE_OF_CONDUCT.md
git add -A && git commit -m "docs: org defaults" && git push

Case 1: unify contribution standards across 200 repositories

Problem: Each repository's CONTRIBUTING and SECURITY files differ or are missing, so the security team does not receive vulnerability reports. Approach: In the organization's public .github repository, put SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SUPPORT.md and a generic issue form; repositories that need special templates bring their own ISSUE_TEMPLATE/ (mind the wholesale replacement rule). Limitation: CODEOWNERS and LICENSE cannot be distributed this way; use repository templates or a bulk PR script.

Case 2: issue forms cut “cannot reproduce” reports from 40% to 10%

Approach: The bug form requires the version (/healthz output), run method (dropdown), logs (render: shell) and a “searched for duplicates” checkbox; blank_issues_enabled: false questions are directed to Discussions. Lesson: Keep fields to no more than 6, otherwise users give up on submitting.

Case 3: a CODEOWNERS error leaves PRs without reviewers

Problem: The team thought /src/ @org/backend was in effect, but the PR actually requested nobody. Root cause: The team had only Read on the repository (a code owner needs explicit Write), so the line was treated as invalid and skipped; another rule *.py @alice placed later overrode it. Approach: Grant the team Write, and use the codeowners/errors API to validate in CI, and adjust the rule order.

Common errors and fixes

The new-issue page does not show my issue form

Cause: YAML syntax error or a missing required top-level key (name,description,body); the file is not in the default branch's .github/ISSUE_TEMPLATE/; the extension is not .yml/.yaml; id duplicated.

Fix: Open the YAML file on the web; GitHub shows form validation errors. Check the indentation with a YAML validator.

CODEOWNERS did not request review
gh api repos/{owner}/{repo}/codeowners/errors --jq '.errors[] | {line, kind, message}'

Cause: The file is not on the base branch; the owner has no explicit Write, or the team is secret; the PR is a draft; path case does not match; a later rule overrides an earlier one.

Mermaid diagram shows “Unable to render rich display”

Cause: Syntax error, or new syntax that the Mermaid version built into GitHub does not yet support; special characters in node text are not quoted.

Fix: Use ```mermaid + info to check the version; put double quotes around text containing brackets or colons; validate in the Mermaid Live Editor first.

The organization's default CONTRIBUTING is not taking effect

Cause:.github The repository is not public; the repository itself has .github/, the root directory or docs/ already has a file of the same name; the file name is misspelled or has the wrong case.

Command-line questions
1. Check whether the current repository's CODEOWNERS has any syntax errors.
gh api repos/{owner}/{repo}/codeowners/errors --jq '.errors'
2. Use the API to view the repository's community health percentage.
gh api repos/{owner}/{repo}/community/profile --jq .health_percentage
Scenario analysis
The organization .github repository has bug and feature forms; to add an “incident” form, the myapp repository put incident.yml only in its own .github/ISSUE_TEMPLATE/ folder, and put incident.yml there. The result: users report that the bug and feature forms have disappeared. Why, and what should be done?

As soon as a repository defines its own valid issue template or config.yml, the organization's .github repository's ISSUE_TEMPLATE all are no longer used (wholesale replacement, not merged). Solution: also copy bug.yml and feature.yml into myapp's ISSUE_TEMPLATE (a script or repository template can keep them in sync), or put the incident form in the organization's default repository so that all repositories can use it.

Verified instructional videos

▶
Getting started with Markdown on GitHub — GitHub
English · official channel · GFM basic syntax

Official documentation

Video storyboard script (about 90 seconds)

Shot 1 · 0–20s
Scene: a README changes from plain text into a page with alert blocks, a table and a Mermaid architecture diagram.
Narration: GitHub Flavored Markdown makes the README the front door of the project: alert blocks, task lists and diagrams all render directly.
Shot 2 · 20–50s
Scene: the YAML of bug.yml on the left; on the right it turns live into a web form with required fields, and submitting generates a Markdown body.
Narration: issue forms require reporters to supply the version and logs, and the answers are converted into plain Markdown.
Shot 3 · 50–75s
Scene: a magnifying glass scans .github, the root directory and docs in turn, and finally flies to the organization's .github repository.
Narration: GitHub looks for files in the order .github, root directory, docs; only if none is found does it use the organization's default files.
Shot 4 · 75–90s
Scene: the CODEOWNERS and LICENSE files are blocked from the organization's default repository.
Narration: but CODEOWNERS and LICENSE cannot be defaulted; they must be placed in every repository.
or get a score of ≥ 70% in the quiz

Module 7 · Notifications, search and productivity

43:00 – 50:00 · subscribe only to what you need, search for what you are looking for, and save every click with keyboard shortcuts and saved replies
7 minNew code search syntax★★★☆☆
Learning objectives
  • Distinguish watching and participating notifications, choose the right Watch level, configure delivery channels (web inbox, email, GitHub Mobile), and sort them with inbox filters (reason:,is:).
  • Master code search syntax (repo:,org:,language:,path:,symbol:, regex, boolean operators) and issue/PR search qualifiers (review-requested:@me,involves:@me , etc.).
  • Use saved replies and common keyboard shortcuts to improve daily efficiency.
Prerequisite knowledge: Modules 3 and 4. Importance:★★★☆☆ (does not affect functionality, but determines how much time you spend on GitHub each day)

What: two kinds of notifications

  • Participating: conversations you have commented on, been @mentioned in, been assigned to, been asked to review, authored, or where a team you belong to has been @mentioned.
  • Watching: activity in repositories you watch (at the level you choose).

Watch levels

LevelWhat you receiveSuitable for
Participating and @mentionsOnly participating conversationsDefault recommendation; most repositories
All ActivityAll activity in the repositoryA few repositories you maintain
CustomParticipating + selected events: Issues, Pull requests, Releases, Discussions, Security alertsDependency projects where you only follow releases
IgnoreNothing (not even @mentions)Noisy repositories (use with caution)

Delivery and inbox

  • Channels: web inbox, GitHub Mobile (working hours can be set), email (notifications can be routed by organization to different verified email addresses). To use the web or mobile inbox, enable the corresponding type in settings On GitHub.
  • Notifications in the inbox are kept for 3 months, marked as Saved are kept indefinitely; after handling, mark them as Done (is:done can be recovered).
  • Filters: is:unread,is:saved,is:done,is:pr,is:issue,is:release,reason:review-requested,reason:mention,reason:team-mention,reason:assign,reason:participating,reason:ci-activity,reason:security-alert,repo:,org:,author:; up to 15 custom filters.
  • Reducing noise: for team review requests you can enable “notify only requested members” or automatic assignment; for conversations you don't need, click Unsubscribe; Actions run notifications can be sent only on failure.

Search: keep the three syntaxes apart

Code search (web, new engine)Issue / PR / repository searchREST code search API / gh search code
qualifiersrepo: org: user: language: path: symbol: content: is:archived is:fork is:vendored is:generatedis:open is:pr author: assignee: label: review-requested: involves: draft: review: sort:Legacy code search syntax (legacy),does not support regex and symbol:
advanced capabilitiesRegex /sparse.*index/,AND/OR/NOT, parentheses, exact phrases "...",path: Supports glob (*,**)no:assignee,-label:wontfix (exclusion), date ranges updated:>2026-11-01subject to a dedicated per-minute rate limit
RequirementRequires sign-in—Requires authentication

Common search recipes

PurposeQuery
PRs awaiting my reviewis:pr is:open review-requested:@me archived:false
All open conversations I have participated inis:open involves:@me sort:updated-desc
My PRs with failing checksis:pr is:open author:@me status:failure
Who in the organization still uses a certain functionorg:myorg-lab language:python symbol:get_redis
Find accidentally committed key patterns (excluding tests)repo:OWNER/myapp /AKIA[0-9A-Z]{16}/ NOT path:**/tests/**
Checkouts in all workflows that are not pinned to a SHAorg:myorg-lab path:.github/workflows /uses: actions\/checkout@v\d/

Saved replies and shortcuts

  • Saved replies: belong to a personal account, can be used across repositories and organizations, and can be inserted in issues, PRs and discussions; up to 100 items; one built-in “Duplicate issue”. In the comment box, press Ctrl+. to open the menu, then press Ctrl+ number to insert.
  • Site-wide:? shows all shortcuts for the current page;S or / focuses search;G N notifications.
  • Repository:G C code,G I issues,G P PRs,G A Actions;. opens in the github.dev web editor.
  • Browsing code:t file finder,w switch branch/tag,b blame view,y expand the URL into a permanent link with SHA.
  • Issue/PR lists and comments:Ctrl+/(on Mac it is ⌘) focuses the filter box,L label,A assign,R reply quoting the selected text.

When: a sustainable personal workflow

  1. Default Watch = Participating; All Activity only for repositories you maintain; dependency projects Custom → Releases.
  2. Process the inbox twice a day: first reason:review-requested, then reason:mention, and mark the rest Done in bulk.
  3. Bookmark a few search URLs (PRs awaiting my review, my failing PRs, conversations I'm in), or turn them into gh aliases.
  4. Turn common replies into saved replies (thanks for contributing, please add reproduction steps, duplicate issue).
Common misconceptions (1) “Ignore only skips ordinary activity”: Ignore also stops @mention notifications. (2) “gh search code uses the same syntax as web code search”: the API uses the legacy syntax, which does not support regex and symbol:. (3) “Notifications are kept forever”: the inbox keeps them for only 3 months; mark the ones you need as Saved. (4) “Saved replies are shared at the repository level”: they belong to a personal account; templates shared across a team belong in issue/PR templates.

How notifications are generated and delivered

Repository events @you mentionedReview requested from youAssignedNew issue / PR / releaseActions run failedDependabot / security alerts@org/team mentioned Subscription checkparticipating?watching level allows? Personal settingsOn GitHub / Email / MobileRoute email by organization Web inboxKept 3 months / Saved permanently GitHub MobileWorking hours EmailEmail client rules Sortingreason:review-requestedreason:mentionreason:ci-activityis:saved / is:donerepo: · org: · author:≤ 15 custom filters
Figure 7-1: whether you are notified is decided by “participating / watching”; where it is delivered is decided by personal settings; the inbox is sorted with filters

Structure of a code search query

org:myorg-lab language:python /redis\.Redis\(/ NOT path:**/tests/** ScopeFilterContent (regex)Exclude space = AND
Figure 7-2: qualifiers are ANDed by default; regex is enclosed in slashes, and metacharacters such as brackets need escaping

Query builder: assemble a code / issue / PR search

Choose the search type and fill in the conditions; below, the query string, a directly openable GitHub search URL, the equivalent gh command, and an explanation of each qualifier are generated in real time.

Query

Commands and API

CommandPurposeNotes
gh api notificationsList unread notifications-f all=true,-f participating=true (GET needs --method GET)
gh api -X PUT notificationsMark all as readcan take -f last_read_at=…
gh api -X PUT repos/O/R/subscription -F subscribed=trueWatch repository (All Activity)-F ignored=true for Ignore; DELETE Unsubscribe
gh search prs / issues / reposSearch--review-requested=@me,--state open,--json
gh search codeCode search (API, legacy syntax)--repo,--language,--filename,--extension
gh statusCross-repository overview: issues/PRs assigned to you, review requests, mentions, repository activity-o ORG Restrict to an organization
gh status
Assigned Issues                       │ Assigned Pull Requests
your-login/myapp#5  Document version… │ Nothing here ^_^
                                      │
Review Requests                       │ Mentions
myorg-lab/myapp#2  docs: add CONT…    │ Nothing here ^_^
gh search prs --review-requested=@me --state open --json repository,number,title \
  --jq '.[] | "\(.repository.nameWithOwner)#\(.number)\t\(.title)"'
gh api notifications --method GET -f participating=true \
  --jq '.[] | {reason, type: .subject.type, title: .subject.title, repo: .repository.full_name}'
myorg-lab/myapp#2	docs: add CONTRIBUTING
{"reason":"review_requested","repo":"myorg-lab/myapp","title":"docs: add CONTRIBUTING","type":"PullRequest"}

In the API, reason uses underscores (review_requested), while web inbox filters use hyphens (reason:review-requested).

# To follow only the releases of a dependency project: web Watch → Custom → Releases
# Subscribe or ignore via the API:
gh api -X PUT repos/cli/cli/subscription -F subscribed=true --jq '{subscribed, ignored}'
gh api -X DELETE repos/cli/cli/subscription      # unsubscribe

Lab 7: build your “10-minute daily” workspace (about 5 min)

Goal: configure Watch, custom inbox filters, search bookmarks, saved replies and gh aliases.
Notification settings:Settings → Notificationsfor Participating, tick On GitHub and Email; for Watching, tick only On GitHub; for Actions, choose to notify only for failed workflows. In the myapp repository, top-right Watch → All Activity; keep other repositories on Participating and @mentions.
Custom inbox filters:github.com/notifications → gear icon next to Filters → Add:
  • 👀 Review: reason:review-requested is:unread
  • 📣 Mentions: reason:mention reason:team-mention (multiple reasons are OR-ed; follow what the interface actually shows)
  • 🔴 CI: reason:ci-activity
Code search practice (sign in on the web first): type in the top search box and observe the results:
repo:your-login/myapp symbol:healthz
repo:your-login/myapp path:.github/workflows /actions\/checkout@v\d/
repo:cli/cli language:go symbol:NewCmdApi

The second query finds checkouts not pinned to a SHA; Lesson 5 fixes this.

Saved replies:Settings → Saved replies Create a new “Need repro”: Thanks! Could you share the output of `curl -s localhost:8000/healthz` and the steps to reproduce?. In any issue comment box, press Ctrl+. to insert it.
gh aliases:
gh alias set review 'search prs --review-requested=@me --state open'
gh alias set failing 'search prs --author=@me --state open --checks=failure'
gh review; gh failing; gh status
Shortcut practice: open the myapp repository and press in turn t(find app.py) → b(blame) → y(permalink) → G P(PR list) → ?(show all shortcuts).

Case 1: a platform engineer receiving 400 notification emails a day

Problem: On joining the company, 300 repositories in the organization were automatically watched (“Automatically watch repositories” was on); the emails were completely unreadable, and real review requests were missed. Approach: Turn off automatic watching; in github.com/watching bulk-unwatch; Watching is delivered only to the web inbox; email keeps only Participating; set up three inbox filters: Review, Mentions, CI. Result: Notifications to handle each day dropped to under 30.

Case 2: an emergency security investigation using code search

Problem: After the tj-actions/changed-files supply-chain incident (CVE-2025-30066) was disclosed, the security team needed to know within an hour which workflows in the organization used it. Approach: Web code search org:ORG path:.github/workflows tj-actions/changed-files gave a complete list; then regex was used to separate references by tag from usages pinned by SHA; bulk PRs replaced them or pinned them to the fixed version. Lesson: Code search (new engine) is far more powerful than the API's legacy syntax; prefer the web during emergencies. See Lessons 5 and 6.

Case 3: a unified “first response” experience across the team

Approach: Maintainers turned “thanks for contributing + next steps”, “please add reproduction steps” and “duplicate issue” into saved replies, and stated response time limits in CONTRIBUTING; they used is:issue is:open no:label a search bookmark to sort new issues once a day.

Common errors and fixes

Requested for review but received no notification

Cause: Participating's On GitHub/Email is turned off; you Ignored the repository; a team was requested and automatic assignment is on (only the assigned person is notified); the email was filtered into spam.

gh api repos/OWNER/REPO/subscription --jq '{subscribed, ignored}'
Code search returns “Sign in to search code”, or cannot find code just pushed

Cause: Code search requires sign-in; newly pushed content needs time to be indexed; search mainly covers the default branch (follow the official documentation); archived or forked repositories may be excluded by default (use is:archived,is:fork).

gh search code 'symbol:foo' returns no results / errors

Cause: The API uses the legacy code search syntax, which does not support symbol: and regex.

Fix: Use the new syntax on the web; in scripts use gh search code foo --repo O/R --language python.

HTTP 403: API rate limit exceeded (search)

Cause: The search API has its own, lower per-minute limit. Fix:gh api rate_limit --jq .resources.search Check the rate limit status; add delays in scripts.

Command-line questions
1. List all open PRs that have requested your review (across repositories).
gh search prs --review-requested=@me --state open
2. Set cli/cli to Ignore (no longer receive any notifications).
gh api -X PUT repos/cli/cli/subscription -F ignored=true
Scenario analysis
You maintain 5 repositories and are also a member of 200 repositories in an organization. Design a notification and search strategy that ensures you don't miss reviews and security alerts, without being drowned in noise.

Watch: All Activity for the 5 maintained repositories (or Custom: Issues + PR + Releases + Security alerts), Participating for the rest; turn off automatic watching. Delivery: Participating → web + email; Watching → web only; Actions notifies only on failure; organization notifications routed to a work mailbox. Inbox filters: reason:review-requested,reason:security-alert,reason:mention,repo: (one per maintained repository, no more than 15 in total). Search bookmarks: is:pr is:open review-requested:@me,is:issue is:open no:label repo:…. Process at two fixed times each day; mark handled items Done and items needing follow-up Saved.

Verified instructional videos

▶
How to use Git and GitHub in VS Code | Tutorial for beginners — GitHub
English · official channel · handling PRs and issues in the editor to reduce context switching

No verified video specifically explaining notification filters and the new code search syntax was found; follow the official documentation and storyboard script below.

Official documentation

Video storyboard script (about 90 seconds)

Shot 1 · 0–20s
Scene: 400 notification emails pile up in the mailbox, then a “Participating” filter compresses them to 20.
Narration: notifications come in two kinds, participating and watching. By default you follow only participating conversations, and the noise drops by an order of magnitude at once.
Shot 2 · 20–45s
Scene: three custom filters on the left of the inbox: Review, Mentions, CI; clicking one changes the list instantly.
Narration: use reason filters to sort; handle review requests first, then mentions, and mark the rest Done.
Shot 3 · 45–75s
Scene: in the search box, org:, language:, regex and NOT path: are typed in turn, and the results narrow step by step.
Narration: the new code search supports qualifiers, regex and boolean operators. Note that the API uses the legacy syntax.
Shot 4 · 75–90s
Scene: on the keyboard, t, b, y, G P light up in turn, and in the comment box Ctrl+. pops up the saved replies.
Narration: shortcuts and saved replies save you hundreds of clicks every day.
or get a score of ≥ 70% in the quiz

Module 8 · Collaboration readiness review and introductory troubleshooting

50:00 – 60:00 · the standard for a repository being “ready to hand to a team”, and how to locate the most common platform problems
10 minInteractive troubleshooting tree★★★★☆
Learning objectives
  • Use a collaboration readiness checklist to review a repository: access control, branch protection, merge settings, community files, security baseline, automation and observability, and be able to check them automatically with gh scripts.
  • Master the general order for platform troubleshooting: identity → host → permission → rules → status, and be able to tell apart the meanings of 401 / 403 / 404 / 422.
  • Independently troubleshoot four introductory problem types: insufficient permissions (403/404), PRs that cannot be merged (checks / conflicts / rules), notification overload, and gh authentication failures.
Prerequisite knowledge: Modules 1–7. Importance:★★★★☆

What: what collaboration-ready means

Before a repository is handed to a team, it should let new members participate without asking anyone know how to take part, and keep incorrect changes from getting into main, and make problems visible. Below are the six groups of checks summarized in this lesson:

CategoryChecksSource module
Access controlOrganization base permission Read or None; grant by team; Admin ≤ 3 people; outside collaborators reviewed periodically; organization requires 2FAM2
Branch protectionmain has a ruleset: require PR (≥1 approval, dismiss old approvals), required checks, conversations resolved, block force pushes and deletionsM4
Merge settingsEnable only the merge methods the team has agreed on (e.g. squash only); automatically delete branches after merging; allow auto-mergeM4
Community filesREADME, CONTRIBUTING, PR template, issue forms + config.yml, CODEOWNERS (error-free), SECURITY.md, LICENSE (public repositories)M6
PlanningLabel system, issue types, milestones or a Project; Discussions handle Q&A (optional)M3
Security and automationCI as a required check; Dependabot alerts; enable secret scanning and push protection on public repositories (private repositories need Secret Protection, Lesson 6)M1, Lessons 2 and 6

Why: review before delivery

  • The later rules are added, the more painful they are: once a dozen open PRs exist, requiring linear history or required checks means every PR has to be reworked.
  • Most “GitHub is broken” tickets are actually permission or rule configuration problems; a readiness review eliminates them in advance.

How: the general order for platform troubleshooting

  1. Identity: who am I? gh auth status,gh api user --jq .login,git config credential.helper, environment variables GH_TOKEN.
  2. Host: where is the request going? github.com,*.ghe.com or GHES? git remote -v,GH_HOST.
  3. Permission: what role do I have on this resource? collaborators/USER/permission; token scopes or fine-grained permissions; whether SAML SSO is authorized.
  4. Rules: which rulesets, branch protection or enterprise policies apply to it? rules/branches/main; greyed-out settings.
  5. Status: the PR's mergeStateStatus, check results,githubstatus.com platform status.

Quick reference for HTTP status codes

Status codeTypical meaning on GitHubWhat to check first
401 Bad credentialsToken invalid, expired or revokedgh auth status, leftover GH_TOKEN
403 ForbiddenIdentity valid but permissions insufficient; token lacks scope; SAML SSO not authorized; rate limit; rejected by rulesthe full response message,x-ratelimit-remaining, role
404 Not FoundResource does not exist or you have no right to know it exists (private repositories return 404 to people without access)spelling, host, whether you have any access at all
409 ConflictState conflict, such as the head changing during a merge or an empty repositoryRe-fetch the latest state
422 UnprocessableParameter validation failed, PR not mergeable, duplicate creationthe errors array in the response
429 / 403 + rate limitPrimary or secondary rate limitretry-after,x-ratelimit-reset

When: when to do a readiness review

When creating a new repository (set everything up in one go with a template repository or a script), when transferring a repository from a personal account to an organization, before open-sourcing, and once a quarter (access review).

Common misconceptions (1) “A 404 means the repository was deleted”: more often you lack permission or signed in with the wrong account. (2) “I'm an admin, so rulesets don't apply to me”: unless you are on the bypass list, admins are also bound by rulesets (legacy branch protection has a “Do not allow bypassing” option). (3) “If gh authentication succeeds, git push will work too”: git may use another credential helper (GCM, SSH keys); check the two separately, or run gh auth setup-git.

Troubleshooting order: from identity to status

(1) Identitygh auth statusGH_TOKEN / GCM / SSH→ 401 (2) Hostgit remote -vGH_HOST · ghe.com→ 404 (3) Permission…/permission role_nametoken scope · SSO→ 403 / 404 (4) Rulesrules/branches/mainenterprise / organization policies→ GH013 / 405 (5) StatusmergeStateStatuschecks · githubstatus→ BLOCKED / DIRTY At each step, use one command to get a yes/no answer; don't skip steps: 90% of problems can be located within the first three steps When reporting a problem to GitHub Support, include the x-github-request-id response header and the time (UTC)
Figure 8-1: the five-step method for platform troubleshooting

Readiness review radar

Access controlBranch protectionMerge settingsCommunity filesPlanningSecurity and automation Example: myapp at the end of this lessonMerge settings and security still have gaps Scorer on the animation pagegives your actual score
Figure 8-2: six dimensions; gaps usually appear in “Merge settings” (branch deletion or a unified merge method not enabled) and “Security”

Readiness scorer

Tick the items your repository already meets (or run the script on the “Commands” page and fill in the comparison); the scorer gives a weighted score across six dimensions, a grade and priority fix recommendations.

Automated readiness check script (gh + built-in jq)

#!/usr/bin/env bash
# Usage: bash gh-readiness.sh OWNER/REPO
set -uo pipefail
R=${1:?OWNER/REPO}
pass(){ printf '  \033[32mPASS\033[0m %s\n' "$1"; }
warn(){ printf '  \033[33mWARN\033[0m %s\n' "$1"; }

echo "== Repo settings"
S=$(gh api repos/$R)
[ "$(jq -r .delete_branch_on_merge <<<"$S")" = true ] && pass "delete branch on merge" || warn "enable delete_branch_on_merge"
[ "$(jq -r .allow_merge_commit <<<"$S")" = false ] && pass "merge commits disabled" || warn "merge commits allowed (team convention?)"
[ "$(jq -r .allow_auto_merge <<<"$S")" = true ] && pass "auto-merge allowed" || warn "auto-merge not allowed"
DEF=$(jq -r .default_branch <<<"$S")

echo "== Branch rules on $DEF"
RULES=$(gh api repos/$R/rules/branches/$DEF --jq '[.[].type] | unique | join(",")')
for t in pull_request required_status_checks non_fast_forward deletion; do
  [[ ",$RULES," == *",$t,"* ]] && pass "rule $t" || warn "missing rule $t"
done

echo "== Community files"
gh api repos/$R/community/profile --jq '.files | to_entries[] | "\(.key)=\(.value != null)"' 2>/dev/null | while IFS='=' read k v; do
  [ "$v" = true ] && pass "$k" || warn "missing $k"; done
E=$(gh api repos/$R/codeowners/errors --jq '.errors | length' 2>/dev/null || echo "n/a")
[ "$E" = 0 ] && pass "CODEOWNERS valid" || warn "CODEOWNERS errors: $E (or file missing)"

echo "== Security"
jq -r '.security_and_analysis // {} | to_entries[] | "\(.key) \(.value.status)"' <<<"$S" | while read k v; do
  [ "$v" = enabled ] && pass "$k" || warn "$k $v"; done

echo "== Access"
gh api "repos/$R/collaborators?affiliation=direct" --jq '.[] | "\(.login) \(.role_name)"' 2>/dev/null | sed 's/^/  direct: /'
gh api "repos/$R/collaborators?affiliation=outside" --jq 'length' 2>/dev/null | xargs -I{} echo "  outside collaborators: {}"
== Repo settings
  WARN enable delete_branch_on_merge
  WARN merge commits allowed (team convention?)
  WARN auto-merge not allowed
== Branch rules on main
  PASS rule pull_request
  PASS rule required_status_checks
  PASS rule non_fast_forward
  PASS rule deletion
== Community files
  WARN missing code_of_conduct
  PASS contributing
  PASS issue_template
  WARN missing license
  PASS pull_request_template
  PASS readme
  PASS CODEOWNERS valid
== Security
  PASS secret_scanning
  PASS secret_scanning_push_protection
  WARN dependabot_security_updates disabled
== Access
  outside collaborators: 0

The script uses the system jq to process the fetched JSON (Windows Git Bash can winget install jqlang.jq), and the gh part uses only the built-in --jq. security_and_analysis Returned only to people with admin permissions; the set of fields varies by plan.

Quick reference of troubleshooting commands

ProblemCommand
Who am I / token scopesgh auth status; gh api -i user | grep -i x-oauth-scopes
which credential git usesgit config --show-origin --get-all credential.helper; GIT_TRACE=1 git ls-remote origin 2>&1 | grep -i credential
my role on the repositorygh api repos/O/R --jq .permissions; …/collaborators/ME/permission --jq .role_name
rules applying to the branchgh api repos/O/R/rules/branches/main
why a PR cannot be mergedgh pr view N --json mergeStateStatus,mergeable,reviewDecision,statusCheckRollup
Rate limitgh api rate_limit --jq .resources.core
Platform statusgithubstatus.com(also available as RSS/API)

Lab 8: run a readiness review on myapp and fix it (about 7 min)

Goal: run the readiness script, bring WARN items to an acceptable level, and reproduce two common failures.
Run the script: save the script from the “Commands” page as ~/gh-readiness.sh:
bash ~/gh-readiness.sh $(gh repo view --json nameWithOwner --jq .nameWithOwner)
Fix merge settings:
gh repo edit --delete-branch-on-merge --enable-auto-merge --enable-merge-commit=false --enable-squash-merge --enable-rebase-merge=false
gh repo view --json deleteBranchOnMerge,mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed
gh api repos/{owner}/{repo} --jq .allow_auto_merge
{"deleteBranchOnMerge":true,"mergeCommitAllowed":false,"rebaseMergeAllowed":false,"squashMergeAllowed":true}
true

The ruleset allows squash and rebase, while the repository enables only squash. The two are intersected, so the result is squash only. (If the rule allows only rebase and the repository disables rebase, the PR cannot be merged.)

Add LICENSE and CODE_OF_CONDUCT (via a PR):
git switch main && git pull && git switch -c docs/license
gh api licenses/mit --jq .body | sed "s/\[year\]/2026/; s/\[fullname\]/$(gh api user --jq '.name // .login')/" > LICENSE
git add LICENSE && git commit -m "docs: add MIT license" && git push -u origin docs/license
gh pr create --fill && gh pr merge --auto --squash
Reproduce failure 1: gh authentication failure:
GH_TOKEN=ghp_invalid gh api user
gh: Bad credentials (HTTP 401)

In the troubleshooting tree on the “Troubleshooting” page, choose “gh authentication failure” and follow the prompts to locate the problem: environment variables take precedence over stored sign-in.

Reproduce failure 2: PR blocked by checks:
git switch -c test/broken
echo "def broken(:" >> app.py
git commit -am "test: break lint" && git push -u origin test/broken
gh pr create --fill
gh pr checks --watch; gh pr view --json mergeStateStatus --jq .mergeStateStatus
lint	fail	10s	https://github.com/your-login/myapp/actions/runs/…
BLOCKED
gh run view --log-failed | tail -5        # see the SyntaxError
gh pr close --delete-branch                # clean up

Case 1: new repositories are “ready out of the box”

Problem: Every team spends half a day configuring each new repository, and items are often missed. Approach: The platform team maintains a template repository (community files, CI, CODEOWNERS placeholders) + organization-level rulesets (Lesson 6) + a gh bootstrap script (merge settings, team access, label cloning gh label clone); new repositories are ready in 5 minutes; the readiness script is run quarterly to produce a report.

Case 2: “I can see the repository but cannot push to it”

Investigation:① gh auth status normal; (2) git remote -v points to the right place; (3) role_name is triage. The problem is permissions: he got Triage through the engineering team, but was never added to the backend team Fix: Join the backend team. Lesson: Locate it in 3 minutes with the five-step method, rather than resetting the SSH key.

Case 3: all scripts suddenly return 403 in an SSO organization

Problem: After the organization enabled SAML SSO, all scripts using old PATs returned 403: Resource protected by organization SAML enforcement. You must grant your Personal Access token access to this organization. Approach: Authorize SSO for the organization in the token settings; switch new scripts to a GitHub App. Lesson: The body of a 403 message is the answer; always read the full message when troubleshooting.

Interactive troubleshooting tree

Start from the symptom you see, answer the questions step by step, and get the diagnosis and fix commands. Covers: insufficient permissions 403/404, PRs that cannot be merged (checks failing / conflicts / rules), notification overload, gh authentication failures, etc.

Common error messages

remote: Write access to repository not granted. fatal: unable to access '…': The requested URL returned error: 403

Cause: The account or token has no write permission; the fine-grained PAT does not include the repository or lacks Contents: Read and write. Fix: See the troubleshooting tree entry “push or API returns 403”.

Resource protected by organization SAML enforcement. You must grant your Personal Access token access to this organization.

Fix: GitHub → Settings → Developer settings → Personal access tokens → that token → Configure SSO → Authorize; for gh users, run gh auth login again and complete SSO in the browser.

GH006: Protected branch update failed for refs/heads/main.

Cause: Legacy branch protection rejected the push (the new ruleset reports GH013). Fix: Go through a PR; check the specific next-line reason (required checks, reviews, etc.).

Command-line questions
1. Use one command to list all rule types that apply to the main branch.
gh api repos/{owner}/{repo}/rules/branches/main --jq '[.[].type] | unique'
2. Confirm which OAuth scopes the current token has.
gh api -i user 2>/dev/null | grep -i '^x-oauth-scopes'
# or gh auth status
Scenario analysis
A new colleague says: “myorg-lab/myapp opens in the browser and git clone works, but git push returns 403, while gh pr create succeeds.” Analyze the possible causes using the five-step method.

(1) Identity: the browser, gh and git may be three different credentials. gh uses an OAuth token, while git may use another account cached in GCM or a read-only fine-grained PAT. Use gh auth status and git config --get-all credential.helper,GIT_TRACE=1 to compare; run gh auth setup-git to unify them. (2) Host: confirm the remote is github.com rather than an old mirror. (3) Permission: role_name if the role is read or triage, you can clone and open PRs (from a fork or an existing branch), but cannot push. Write is needed (join the appropriate team). (4) Rules: if the push targets main, a ruleset rejects it even with Write (usually as GH013 rather than 403). (5) SSO: if the organization enables SAML, a PAT that has not been authorized for SSO also gets 403.

Verified instructional videos

▶
Git and GitHub Tutorial for Beginners — Kevin Stratvert
English · community channel · a comprehensive review of the repository, branch and PR collaboration workflow
▶
Answering the most common GitHub beginner questions — GitHub
English · official channel · answers to common confusions

No verified video specifically explaining the five-step GitHub platform troubleshooting method was found; the official documentation and storyboard script below apply.

Official documentation

Video storyboard script (about 90 seconds)

Shot 1 · 0–25s
Scene: a repository is like a pre-flight checklist; six categories are ticked in turn, and the radar chart gradually fills in.
Narration: before handing it to a team, run a collaboration readiness review: permissions, branch protection, merge settings, community files, planning, security.
Shot 2 · 25–60s
Scene: five steps: identity, host, permission, rules, status; beside each step is a command and its output.
Narration: don't guess when you hit a problem. Follow the five steps: who am I, where is the request going, what is my role, which rules apply, what is the current status?
Shot 3 · 60–90s
Scene: the red 404 error page is flipped over, and its back reads “you may not have permission”.
Narration: remember, private resources return 404 to people without permission. Read the full error message; the answer is usually in it.
or get a score of ≥ 70% in the quiz

Command cheat sheet

All core commands and syntax of Lesson 1, grouped by scenario
gh 2.104.0REST 2026-03-10

Installation and authentication

winget install --id GitHub.cli     # Windows
brew install gh                    # macOS
sudo apt install gh                # first add the apt source from cli.github.com
gh auth login --web --git-protocol https
gh auth status
gh auth refresh -s project,workflow
gh auth setup-git
gh auth switch                     # switch between multiple accounts
GH_TOKEN=... gh api user           # scripts / CI
GH_HOST=octocorp.ghe.com gh api user

Repositories

gh repo create myapp --public --source=. --push
gh repo create NEW --public --template OWNER/TPL --clone
gh repo view --json name,visibility,defaultBranchRef
gh repo edit --delete-branch-on-merge --enable-auto-merge
gh repo edit --enable-merge-commit=false --enable-rebase-merge=false
gh repo edit --visibility private --accept-visibility-change-consequences
gh repo edit --enable-discussions
gh api repos/USER/REPO/transfer -f new_owner=ORG

Permissions and teams (REST)

gh api repos/O/R/collaborators/U/permission --jq .role_name
gh api "repos/O/R/collaborators?affiliation=outside"
gh api -X PUT repos/O/R/collaborators/U -f permission=triage
gh api orgs/ORG/teams -f name=backend -f privacy=closed -F parent_team_id=ID
gh api -X PUT orgs/ORG/teams/backend/repos/ORG/R -f permission=push
gh api -X PATCH orgs/ORG -f default_repository_permission=read
# permission: pull | triage | push | maintain | admin

Issues / Projects

gh label create "area/api" --color 1d76db --force
gh label clone OWNER/TEMPLATE-REPO
gh api repos/{owner}/{repo}/milestones -f title=v1.2.0
gh issue create -t T -b B -l bug -a @me -m v1.2.0
gh issue create -t T -b B --parent 3
gh issue edit 3 --add-sub-issue 7,8
gh issue develop 4 --checkout
gh issue close 4 --reason "not planned"
gh project create --owner @me --title "roadmap"
gh project item-add 1 --owner @me --url ISSUE_URL

Pull requests

gh pr create --draft --fill --body "Closes #4"
gh pr ready
gh pr checkout 6
gh pr diff 6 --name-only
gh pr review 6 --approve | --request-changes -b "…" | --comment -b "…"
gh pr checks 6 --watch --required
gh pr update-branch 6 [--rebase]
gh pr merge 6 --squash --delete-branch
gh pr merge --auto --squash
gh pr merge 6 --squash --match-head-commit SHA
gh pr view 6 --json mergeStateStatus,mergeable,reviewDecision

gh api: REST and GraphQL

gh api repos/{owner}/{repo}/issues --method GET -f state=all
gh api 'repos/{owner}/{repo}/issues?per_page=100' --paginate --slurp --jq 'add|length'
gh api -X PATCH repos/O/R -F allow_auto_merge=true
gh api repos/O/R/rulesets --input ruleset.json
gh api -i user | grep -i x-ratelimit
gh api -H "X-GitHub-Api-Version: 2026-03-10" repos/O/R
gh api graphql -f query='{ viewer { login } rateLimit { cost remaining } }'
gh api graphql --paginate --slurp -f query='query($endCursor:String){…pageInfo{hasNextPage endCursor}}'
gh api rate_limit --jq .resources.core
GH_DEBUG=api gh pr list

Notifications and search

Inbox: reason:review-requested  reason:mention  reason:team-mention
        reason:ci-activity  is:unread  is:saved  is:done  repo:O/R
Code:  repo:O/R  org:ORG  language:python  path:.github/workflows
        symbol:healthz  /regex\(/  NOT path:**/tests/**  "exact phrase"
PR:    is:pr is:open review-requested:@me  involves:@me  author:@me
        status:failure  draft:false  review:approved  sort:updated-desc
Issue: is:issue is:open no:label  label:bug  -label:wontfix  type:Bug
gh status
gh search prs --review-requested=@me --state open
gh api notifications --method GET -f participating=true
gh api -X PUT repos/O/R/subscription -F ignored=true

Community file locations

Lookup order: .github/  →  root  →  docs/  →  public ORG/.github repository
.github/ISSUE_TEMPLATE/bug.yml      Issue form (public preview, issues only)
.github/ISSUE_TEMPLATE/config.yml   blank_issues_enabled / contact_links
.github/pull_request_template.md    PR template (multiple: PULL_REQUEST_TEMPLATE/)
.github/CODEOWNERS                  not default-capable; uses the version on the base branch; last match takes effect
CONTRIBUTING.md  SECURITY.md  SUPPORT.md  CODE_OF_CONDUCT.md  FUNDING.yml
LICENSE (root directory, not default-capable)     ORG/.github/profile/README.md (organization home page)

Shortcuts

?          all shortcuts for the current page        S or /     focus search
G C / G I / G P / G A   code / Issues / PR / Actions
G N        notifications                    .          github.dev editor
t          file finder                w          switch branch/tag
b          blame                   y          permalink (with SHA)
Ctrl+.     saved replies menu          Ctrl+/     focus the issue/PR filter box
L / A      label / assign             R          quote reply

Five-step troubleshooting method

(1) Identity  gh auth status · env | grep GH_TOKEN · git credential helper
(2) Host  git remote -v · GH_HOST · github.com vs *.ghe.com vs GHES
(3) Permission  .../collaborators/ME/permission · token scopes · SAML SSO authorization
(4) Rules  .../rules/branches/main · enterprise/organization policies (greyed-out settings)
(5) Status  mergeStateStatus · gh pr checks · githubstatus.com
401=invalid credentials  403=permissions/scope/SSO/rate limit/rules  404=does not exist or no right to know
422=parameter or state validation failed  429=rate limit

Quick notes on rate limits and plans

ItemValue (docs.github.com, 2026-11-15)
REST primary limitUnauthenticated 60/hour; users 5,000/hour; GITHUB_TOKEN 1,000/hour/repository (GHEC 15,000); GHEC organization App 15,000/hour
GraphQL primary limitusers 5,000 points/hour; GHEC organization App installations 10,000 points/hour; GITHUB_TOKEN 1,000 points/hour/repository
Secondary limit100 concurrent; REST 900 points/minute, GraphQL 2,000 points/minute; content creation generally 80/minute, 500/hour
Repository rolesRead · Triage · Moderate · Write · Maintain · Admin; custom repository roles GHEC only
Issues / ProjectsSub-issues: 100 per parent, 8 levels; issue types up to 25; project fields 50, items 50,000
Free accountsPublic repositories have full features; private repositories cannot enforce branch protection, rulesets or CODEOWNERS; Actions private repositories include a monthly allowance of $12; Packages 500 MB; Codespaces 120 core-hours
Data residencyGHE.com: EU / Australia / US / Japan, EMU only, no public repositories

Integrated lab + completion quiz

Use only the gh CLI to complete issue → branch → PR → review → merge → automatically close issue, and verify the results with REST and GraphQL
About 25 minCovers M1–M8
Scenario Operations feedback: when Redis is unavailable, myapp's root path returns 500 directly; they want it to return 503 with a friendly message, and to let /healthz report the Redis status. You need to complete this fix following the team process: create an issue under the v1.2.0 milestone, create a linked branch from the issue, open a draft PR, go through review and required checks, squash merge, automatically close the issue, and finally use the API to generate a “change evidence” record.
Preparation and self-check (M0, M5, M8)
cd ~/gh-lab/myapp 2>/dev/null || cd ~/myapp
gh auth status && git switch main && git pull --ff-only
REPO=$(gh repo view --json nameWithOwner --jq .nameWithOwner); echo $REPO
gh api repos/$REPO/rules/branches/main --jq '[.[].type] | unique'     # should include pull_request, required_status_checks
Create issue (M3): with labels, milestone, assignee, and optionally set as a sub-issue of a parent issue.
gh label create "area/api" --force >/dev/null
ISSUE=$(gh issue create -t "Return 503 when Redis is unavailable" \
  -b "Root path returns 500 when Redis is down. Expected: 503 with a friendly message; /healthz should report redis status." \
  -l bug -l area/api -a @me -m v1.2.0 | grep -o '[0-9]*$'); echo "issue #$ISSUE"
Create a linked branch from the issue and modify the code (M3, M5)
gh issue develop $ISSUE --name fix/redis-503 --checkout
python - <<'EOF'
import re, pathlib
p = pathlib.Path("app.py"); s = p.read_text()
s = s.replace("from redis import Redis", "from redis import Redis\nfrom redis.exceptions import RedisError")
s = s.replace('''    count = redis.incr("hits")
    return f"Hello from myapp! I have been seen {count} times.\\n"''',
'''    try:
        count = redis.incr("hits")
    except RedisError:
        return "Counter temporarily unavailable, please retry.\\n", 503
    return f"Hello from myapp! I have been seen {count} times.\\n"''')
p.write_text(s)
EOF
python -m py_compile app.py && git diff --stat
git commit -am "fix(api): return 503 when Redis is unavailable"
git push -u origin fix/redis-503

Learners without Python can make the changes directly in an editor. gh issue develop This registers the branch in the issue's Development sidebar.

Open a draft PR and wait for checks (M4)
gh pr create --draft --title "fix(api): return 503 when Redis is unavailable" \
  --body "Closes #$ISSUE

## How was this tested?
- [x] python -m py_compile app.py" -l bug
gh pr checks --watch
gh pr view --json isDraft,mergeStateStatus --jq .
Review and suggested changes (M4, M7)
gh pr ready
# With a partner: the partner leaves a suggestion on the 503 line in Files changed (for example change it to "Service temporarily unavailable"), then:
#   gh pr review --request-changes -b "see suggestion"   → you commit the suggestion → git pull → partner runs gh pr review --approve
# Solo: leave a suggestion yourself and Commit suggestion, then leave a review comment:
gh pr review --comment -b "Self-review: covered RedisError path; healthz change tracked in follow-up."
git pull --ff-only
gh pr checks --watch
Squash merge and automatically close the issue (M4, M3)
PR=$(gh pr view --json number --jq .number)
SHA=$(gh pr view --json headRefOid --jq .headRefOid)
gh pr merge $PR --squash --delete-branch --match-head-commit $SHA
gh issue view $ISSUE --json state,stateReason,closedByPullRequestsReferences \
  --jq '{state, stateReason, closedBy: [.closedByPullRequestsReferences[].number]}'
✓ Squashed and merged pull request your-login/myapp#9 (fix(api): return 503 when Redis is unavailable)
✓ Deleted local branch fix/redis-503 and switched to branch main
✓ Deleted remote branch fix/redis-503
{"closedBy":[9],"state":"CLOSED","stateReason":"COMPLETED"}
Generate “change evidence” with REST and GraphQL (M5)
gh api repos/$REPO/pulls/$PR --jq '{pr: .number, merged, merged_by: .merged_by.login, merged_at, merge_commit: .merge_commit_sha[:7], base: .base.ref}'
gh api repos/$REPO/commits/$(gh api repos/$REPO/pulls/$PR --jq .merge_commit_sha) \
  --jq '{parents: (.parents|length), committer: .commit.committer.name, verified: .commit.verification.verified, message: (.commit.message | split("\n")[0])}'
gh api graphql -F owner="${REPO%/*}" -F name="${REPO#*/}" -F num=$ISSUE -f query='
  query($owner:String!, $name:String!, $num:Int!) {
    repository(owner:$owner, name:$name) {
      issue(number:$num) {
        state milestone { title }
        timelineItems(itemTypes: [CLOSED_EVENT], last: 1) {
          nodes { ... on ClosedEvent { createdAt closer { ... on PullRequest { number mergedAt reviews(first:5){ nodes { state author { login } } } } } } }
        }
      }
    }
  }' --jq '.data.repository.issue'
{"base":"main","merge_commit":"5e6f7a8","merged":true,"merged_at":"2026-11-15T14:32:10Z","merged_by":"your-login","pr":9}
{"committer":"GitHub","message":"fix(api): return 503 when Redis is unavailable (#9)","parents":1,"verified":true}
{"milestone":{"title":"v1.2.0"},"state":"CLOSED","timelineItems":{"nodes":[{"closer":{"mergedAt":"2026-11-15T14:32:10Z","number":9,"reviews":{"nodes":[{"author":{"login":"your-login"},"state":"COMMENTED"}]}},"createdAt":"2026-11-15T14:32:11Z"}]}}
Readiness review and cleanup (M8)
bash ~/gh-readiness.sh $REPO
git log --oneline -3
gh issue list --milestone v1.2.0 --state all --json number,title,state --jq '.[] | "\(.state)\t#\(.number) \(.title)"'

Keep the myapp repository, rulesets and the myorg-lab organization: Lesson 2 (GitHub Actions) continues from here. To clean up test issues: gh issue close N --reason "not planned".

Acceptance checklist

Open-ended self-test (answer first yourself, then expand the reference answer)

1. The company requires code to stay in the EU, sign-in with Entra ID, use of Copilot, and internal repositories for Inner Source. Which deployment should be chosen? What are the costs?

GHEC data residency (GHE.com, EU region) + EMU. Meets data location, IdP identity, Copilot and internal repositories. Costs: no public repositories; EMU accounts are isolated from the open-source community on github.com; the API/network endpoints are *.ghe.com, and some features are temporarily unavailable.

2. Someone is in both a Read team and a Write team, and the organization base permission is Read; what is his effective permission on the repository? How do you make him read-only?

Write (the maximum applies). To make him read-only, you must remove him from the Write team (and confirm there is no direct grant or other high-permission source), rather than adding him to yet another read-only team.

3. A PR says Fixes #12, but after merging the issue is still open. List three possible causes.

The PR was not merged into the default branch; the keyword was in an unrecognized position or malformed; the issue is in another repository but the cross-repository form was not written OWNER/REPO#12. You can use gh pr view --json closingIssuesReferences,baseRefName to check.

4. Compare the effects of squash and merge and rebase and merge on history, SHAs and signatures.

squash: a PR becomes one new commit (single parent); the original commits do not enter base, and GitHub signs the new commit. rebase: each commit is replayed as a new SHA, the committer becomes GitHub, replayed commits have no signature verification, and commits that were already empty are dropped. Both produce linear history.

5. When to use gh pr list, and when to use gh api REST, and when to use GraphQL?

A simple need with a subcommand available → the subcommand (add --json) ; resources not covered by subcommands (milestones, rulesets, teams, permissions) → REST; need to fetch multi-level related data at once or operate on Projects → GraphQL, paying attention to point cost and $endCursor pagination.

6. Organization .github .github repository: how do CODEOWNERS and ISSUE_TEMPLATE each take effect?

CODEOWNERS does not take effect from it. It is not a default-capable community file and must be on each repository's base branch. ISSUE_TEMPLATE is used by default, but as soon as a repository defines its own valid template or config.yml, all of the defaults are no longer used.

Completion quiz (12 questions, covering all modules)

Sources and version notes

Verification basis for all technical facts in this lesson (verified: 2026-11-15)
TopicVerification resultSource (accessed 2026-11-15)
gh CLI version and installationLatest v2.104.0 (released 2026-11-12); Windows winget install --id GitHub.cli --source winget, macOS brew install gh, Debian/Ubuntu use the official apt source from cli.github.comcli/cli releases · install_linux.md
gh command parametersgh auth login (device code, credential store,--with-token minimum scopes repo/read:org/gist,GH_TOKEN,--expiring),gh api (-f/-F,--paginate,--slurp,$endCursor),gh pr merge (--auto,--match-head-commit),gh issue develop,gh repo create --template; --json fields verified to exist on the local gh 2.83cli.github.com/manual
Plans and productsFree: private repositories' Actions include a monthly compute allowance of $12, Packages 500 MB, Codespaces 120 core-hours/15 GB; Pro/Team $18, 2 GB; GHEC $300, 50 GB, 99.9% SLA, EMU, audit log streaming, IP allow list, data residency options; GHAS is split into Secret Protection and Code Security, which require a Team or Enterprise purchaseGitHub's plans · About GHAS
Data residency and GHESGHE.com regions: EU (including Norway and Switzerland), Australia, US, Japan; EMU only; no public repositories; the API is api.SUBDOMAIN.ghe.com. Latest GHES is 3.22 (released 2026-09-08)About GHEC with data residency · GHES releases
Copilot plansFree, Student, Pro, Pro+, Max (individual); Business, Enterprise (organization/enterprise); not available on GHESPlans for GitHub Copilot
Permission modelSix preset roles Read/Triage/Moderate/Write/Maintain/Admin; custom repository roles GHEC only (inherit from Read/Triage/Write/Maintain); base permissions do not apply to outside collaborators, internal repositories are at least read; outside collaborators cannot join teams; personal repositories have only two levels, owner and collaboratorRepository roles · Base permissions · About teams
Issues and ProjectsSub-issues: 100 per parent, 8 levels,gh issue create --parent; issue types default to task/bug/feature, up to 25; Projects have 50 fields; the two workflows “closed → Done” and “PR merged → Done” are enabled by default; the item limit was raised to 50,000 in 2025-04Sub-issues · Issue types · Built-in automations · Changelog 2025-04-08
Pull requestsdrafts cannot be merged and do not automatically request code owners; PR references refs/pull/N/head/merge; required checks must succeed on the latest SHA, with success/skipped/neutral counted as passing; behavioural differences between squash and rebase (rebase generates new SHAs, updates the committer, drops empty commits, no signature verification); auto-merge appears only when a PR cannot be merged immediatelyAbout PRs · Merge methods · Required checks · Auto-merge
Ruleset REST parametersallowed_merge_methods,required_review_thread_resolution,require_last_push_approval,strict_required_status_checks_policy,~DEFAULT_BRANCH; up to 75 rulesets per repositoryREST: Rules · About rulesets
API rate limits and versionsREST: 60/5,000/1,000 (15,000)/15,000; GraphQL: 5,000 points, GHEC App 10,000 points; secondary: 100 concurrent, REST 900 points/min, GraphQL 2,000 points/min; latest REST version 2026-03-10, defaults to 2022-11-28 without the headerREST rate limits · GraphQL limits · API versions
Community filesDefault files require a public .github repository; order .github → root → docs; LICENSE cannot be defaulted; when a repository has its own ISSUE_TEMPLATE, all default templates are not used; CODEOWNERS location .github/root/docs, must be on the base branch, <3 MB, does not support ! and [ ]; issue forms are in public preview; Mermaid/geoJSON/topoJSON/STLDefault community health files · About code owners · Issue forms · Diagrams
Notifications, search, productivityInbox retained for 3 months (Saved permanently), up to 15 custom filters,reason: values; new code search qualifiers and regex; REST code search uses the legacy syntax; up to 100 saved replies,Ctrl+.; shortcut listInbox filters · Code search syntax · Legacy code search · Keyboard shortcuts
GitHub.com metadatagh api meta 's SSH fingerprints and IP range count were measured on 2026-11-15api.github.com/meta

Video verification notes

The videos below were verified for title, channel and video ID through the YouTube oEmbed endpoint (2026-11-15): GitHub “What is GitHub?” (pBy1zgt0XPc), “How GitHub works” (w3jLJU7DT5E), “Answering the most common GitHub beginner questions” (ZgARMqR3qq8), “How to create your first GitHub repository: A beginner's guide | Tutorial” (-RZ03WHqkaY), “How to use GitHub issues and projects | GitHub for Beginners” (c67GaAkf1BE), “Getting started with open source contributions for beginners” (WldXhauP024), “How to create a pull request in 4 min | GitHub for Beginners” (nCKdihvneS0), “How to merge a pull request | Introduction to GitHub” (FDXSgyDGmho), “How to add code to your repository | GitHub beginner tutorial” (g2XjJhrGGg4), “Getting started with Markdown on GitHub” (LxeclcePg-c), “How to use Git and GitHub in VS Code | Tutorial for beginners” (NFjz1AGKA4c); freeCodeCamp.org “Git and GitHub for Beginners - Crash Course” (RGOj5yH7evk); DevInsideYou “#GitHub #CLI - Crash Course” (j5zUoyPaQqc); Kevin Stratvert “Git and GitHub Tutorial for Beginners” (tRZGeaHPoaw). The IDs of GitHub's official videos were taken from the embeds in the “GitHub for Beginners” series on github.blog. oEmbed does not return durations or publish dates, so the durations on the cards are approximate; some videos were recorded earlier, so the interface and commands follow this lesson. No verified dedicated videos were found for the three topics of notifications/code search, organization roles and platform troubleshooting, so storyboard scripts are provided instead.

Voice narration notes

The “Voice” page uses the browser's Web Speech API (speechSynthesis, en-US) to read the narration script aloud in real time, with English terms pronounced in en-US. The result depends on the voices installed on the operating system. The environment that generated this course cannot call a TTS service, so no MP3 is embedded; for offline audio, pass the script to a TTS service.

Known limitations

  • The lab commands were not run one by one against real accounts in the course-generation environment; usernames in the expected output (your-login), issue/PR numbers, SHAs, times, run IDs, ruleset IDs and remaining rate-limit values are all example values. gh api meta fingerprints and counts, and the gh --json field names were verified.
  • GitHub.com is updated continuously: the Moderate role, issue forms (public preview), Copilot plan names, the Actions billing method (calculated in dollar allowances), etc. may change after the course was written; docs.github.com's current version is authoritative.
  • Rulesets cannot be enforced on Free private repositories; merge queues apply only to organization public repositories or GHEC private repositories; custom roles, internal repositories and data residency require GHEC. The course marks plan requirements and gives public-repository alternatives.
  • The event flows, HTTP requests and permission calculations in the animations are illustrations compiled from the official documentation; whether a gh subcommand actually uses REST or GraphQL may change between versions, so verify with GH_DEBUG=api .
  • Details such as where closing keywords are recognized and how issue types are written in search (type:) follow the official documentation if they differ from the interface.
  • macOS's built-in BSD sed must be written as sed -i ''; on Windows, run bash scripts in Git Bash.