GitHub Lesson 1: Core Fundamentals
- 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) andgh apiuse REST and GraphQL directly, master pagination,--jqand rate limits. - Set up community files (README, issue forms, PR templates, CONTRIBUTING, SECURITY.md, CODEOWNERS, organization
.githubrepository 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
| # | Time | Module | Core content | Animation / interaction | Lab (myapp repository) |
|---|---|---|---|---|---|
| 0 | Before class | Environment setup | Account and 2FA, installing gh (Windows / macOS / Linux),gh auth login, creating the myapp repository, optional free organization myorg-lab | Environment self-check list | Push myapp to GitHub |
| 1 | 00–06 | Platform overview and architecture | GitHub.com / GHEC / GHE.com data residency / GHES; enterprise → organization → repository; product line positioning | Deployment forms and hierarchy browser | Use gh api to view account, organization and plan information |
| 2 | 06–14 | Repositories, organizations, teams and permissions | Base permissions, six repository roles, custom roles, nested teams, outside collaborators, visibility | Effective permission calculator (take the highest across sources) | Create teams, grant access, query effective permissions with the API |
| 3 | 14–21 | Issues, Projects and Discussions | Labels, milestones, issue types, sub-issues, Projects views and fields, built-in workflows, Discussions | issue → PR → close → board updates automatically | Create labels, milestones, parent/child issues and a project board |
| 4 | 21–29 | Pull request end-to-end workflow | Draft PRs, reviews, suggested changes, required checks, rulesets, three merge methods, auto-merge | Core animation: event flow of a PR from push to merge + how merge methods affect the commit graph | Draft PR → ready → review → squash merge |
| 5 | 29–37 | gh CLI and REST/GraphQL APIs | gh auth,gh repo/issue/pr/run,gh api, pagination,--jq, rate limits | gh command → HTTP request translator | Query PR data once with REST and once with GraphQL |
| 6 | 37–43 | Markdown, templates and community files | README, issue forms, PR templates, CONTRIBUTING, SECURITY.md, CODEOWNERS,.github repository, Mermaid | Community file resolution order simulator | Add issue forms and a PR template to myapp |
| 7 | 43–50 | Notifications, search and productivity | Watch strategies, notification inbox filtering, code search syntax, issue/PR search, saved replies, keyboard shortcuts | Search query builder | Set up a “my to-do” search and notification filter |
| 8 | 50–60 | Collaboration readiness review and troubleshooting | Repository health checklist, 403/404, PR cannot be merged, notification overload, gh authentication failure | Readiness scorer + interactive troubleshooting tree | Run a readiness review on myapp with a script |
| — | After class | Cheat sheet · Integrated lab | Use gh to complete issue → branch → PR → review → merge → auto-closed issue, and verify with the API | Completion quiz (12 questions) | Integrated lab |
Knowledge Coverage Matrix
| Target skill | M1 | M2 | M3 | M4 | M5 | M6 | M7 | M8 | Key commands / features | Lab |
|---|---|---|---|---|---|---|---|---|---|---|
| Explain deployment forms, hierarchy and product lines | ✓ | ✓ | · | · | · | · | · | · | GHEC / GHE.com / GHES, enterprise / org | M1 lab |
| Grant access by least privilege | · | ✓ | · | ✓ | ✓ | ✓ | · | ✓ | Base permissions, repository roles, teams,/collaborators/{user}/permission | M2 lab |
| Plan and track work | · | · | ✓ | ✓ | ✓ | ✓ | ✓ | · | labels, milestones, sub-issues, Projects | M3 lab |
| Complete and control one PR merge | · | ✓ | ✓ | ✓ | ✓ | ✓ | · | ✓ | gh pr create/review/merge, rulesets | M4 lab · integrated lab |
| Automate with the CLI and API | ✓ | ✓ | ✓ | ✓ | ✓ | · | · | ✓ | gh api --paginate --jq, GraphQL | M5 lab · integrated lab |
| Establish community and contribution standards | · | · | ✓ | ✓ | · | ✓ | · | ✓ | issue forms, PR templates, CODEOWNERS,.github | M6 lab |
| Manage the information flow and find things efficiently | · | · | ✓ | · | · | · | ✓ | ✓ | Watch,reason:,repo: path: symbol: | M7 lab |
| Introductory platform troubleshooting | · | ✓ | · | ✓ | ✓ | · | ✓ | ✓ | gh auth status,mergeStateStatus | M8 lab |
Topics excluded from this lesson (and where to learn them)
| Topic | Why it is not in this lesson | Where to learn it |
|---|---|---|
| Git object model, merge/rebase principles, conflict resolution | Belongs to Git itself | Git Lesson 1,Lesson 2 |
| SSH / HTTPS / GCM authentication, configuration details of rulesets and CODEOWNERS, forks and Inner Source | Already covered in the Git course | Git Lesson 3 |
| GitHub Actions workflow syntax, runners, caching, artifacts | A separate major topic | GitHub Lesson 2 |
| OIDC deployment to Azure / AWS | Cloud platform topic | GitHub Lessons 3 and 4 |
| Reusable workflows, releases, supply-chain attestations | Production-grade Actions | GitHub Lesson 5 |
| GHAS (code scanning, secret scanning, push protection), organization rulesets, audit log, EMU | Enterprise security and governance | GitHub Lesson 6 |
| API rate limits in depth, ARC self-hosted runners, performance tuning | Deep troubleshooting | GitHub Lesson 7 |
How to use this course material
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.
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).
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.
Module 0 · Environment setup (account, gh CLI, practice repository)
- 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 branchmain. - (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
| From | Reused in this lesson | Notes |
|---|---|---|
| Git Lessons 1–2 | commits, branches, merging, rebasing,push -u | this lesson operates only at the platform level and does not re-explain how Git commands work |
| Git Lesson 3 | SSH key or HTTPS + Git Credential Manager | If already configured,gh auth login choose the same protocol when cloning |
| Docker Lesson 1 | myapp 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).
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
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
- 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.
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 by | GitHub | GitHub | GitHub | GitHub (in a specified region) | You (VM / cloud) |
| Access address | github.com | github.com/enterprise's organization | github.com, usernames carry a _shortcode suffix | SUBDOMAIN.ghe.com | your own domain |
| API address | api.github.com | api.github.com | api.github.com | api.SUBDOMAIN.ghe.com | HOST/api/v3,HOST/api/graphql |
| Identity | Personal account | Personal account + organization/enterprise SAML SSO | Managed accounts provisioned by the IdP via SCIM; sign in via SAML or OIDC | EMU only | Built-in, LDAP, SAML, CAS |
| Public repositories | Yes | Yes | No (use internal for Inner Source) | No | Yes (visible only within the instance) |
| Data location | US by default | US by default | US by default | EU (including Azure regions in Norway and Switzerland) / Australia / US / Japan | You decide |
| Feature updates | Continuous | Continuous | Continuous | Continuous (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
| Product | What it solves | Availability on Free accounts (2026-11 docs) | See |
|---|---|---|---|
| GitHub Actions | Event-driven CI/CD and automation | Public 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 Packages | Hosted container images (ghcr.io), npm, Maven, NuGet and other packages | Free: 500 MB storage (Pro / Team: 2 GB; GHEC: 50 GB) | Lessons 2 and 5 |
| Codespaces | Cloud development containers (devcontainer) | Personal accounts get 120 core-hours and 15 GB storage per month | Lesson 7 |
| GitHub Advanced Security | Split 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 plan | Lesson 6 |
| GitHub Copilot | AI coding assistant, code review, coding agent | Copilot Free (limited quota); personal paid Pro / Pro+ / Max; organizations Business / Enterprise; not available on GHES | Lessons 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
| GitHub | Azure DevOps | GitLab | |
|---|---|---|---|
| Core | Repositories + PRs + Actions + security + Copilot | Repos + Boards + Pipelines + Artifacts + Test Plans | One application covering SCM through deployment |
| Hierarchy | Enterprise → organization → repository | Organization → project → repository | Instance → group/subgroup → project |
| Self-hosted | GHES | Azure DevOps Server | GitLab Self-Managed |
| Work items | Issues + Projects (lightweight) | Boards (heavyweight work items, process templates) | Issues + Epics |
Architecture diagram: deployment forms and account hierarchy
Product line map: platform services touched by one commit
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.
Core commands: use gh to see “where you are, who owns it, and what plan it is”
| Command | Purpose | Notes |
|---|---|---|
gh auth status | Currently logged-in host, account, token scopes | When multiple hosts are used (github.com + GHE.com + GHES), all are listed |
gh api user | Current user information | includes plan (visible only to yourself),two_factor_authentication |
gh api user/memberships/orgs | which organizations I belong to and my role in each | role: admin (owner) or member |
gh api orgs/ORG | Organization information | Owners can see plan,default_repository_permission (base permissions) |
gh auth login --hostname SUBDOMAIN.ghe.com | Sign in to GHE.com / GHES | and then use GH_HOST or -R HOST/OWNER/REPO to select the host |
gh api meta | GitHub.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)
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.
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.
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.)
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.
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
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
Official documentation
- GitHub's plans
- About GitHub Enterprise Cloud with data residency
- GitHub Enterprise Server releases
- About GitHub Advanced Security
- Plans for GitHub Copilot
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.
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.
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.
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.
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.
Module 2 · Repositories, organizations, teams and the permission model
- 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).
What: two kinds of repository ownership
| Personal account repository | Organization repository | |
|---|---|---|
| Permission levels | Only two levels: owner (full control) and collaborator | Six preset roles + base permissions + teams + (GHEC) custom roles |
| What collaborators can do | A fixed set of permissions: push, manage issues/PRs, etc.; cannot change visibility, invite others or delete the repository | Determined by the assigned role |
| Suitable for | personal projects and small-scale collaboration | teams, companies, anything needing division of labour and auditing |
| Upgrade path | When 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)
| Role | Designed for | Typical capabilities (excerpted from the official permissions table) | Cannot do |
|---|---|---|---|
| Read | People who only need to view and discuss | Clone/pull, fork, open issues, comment, submit review comments (not an approving “required review”) | Push, apply labels, close others' issues |
| Triage | People who actively organize issues/PRs but do not write code | Add/remove labels and milestones, assign, close/reopen All issues and PRs, mark duplicates, request reviews | Push, merge, give valid approval in “required reviews” |
| Moderate | Community moderators | On 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 permission | Push, merge |
| Write | People who contribute code day to day | Push branches,merge PRs, valid approvals/request changes, enable auto-merge, manage Actions workflows and secrets, publish releases, act as a code owner | Change repository settings, manage access, manage rulesets |
| Maintain | Project managers / maintainers | Write + edit description and topics, configure PR merge methods, enable Wiki/Discussions, configure Pages, limit interactions | Sensitive/destructive actions: delete repository, change visibility, manage access, manage rulesets |
| Admin | People who need full control | Everything: 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
| Visibility | Who can see it | Available scope | fork |
|---|---|---|---|
| public | Everyone on the internet (on GHES, all users of the instance) | All plans (except EMU / GHE.com) | Anyone can fork; forks are public |
| private | Owners and authorized people; organization repositories also include members who can see it under base permissions | All plans | The organization can set whether private forks are allowed |
| internal | Members 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
- Organization owner → admin, done.
- 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.
- 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.
- 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.
Permission source diagram: where a person's effective permissions come from
Role ladder: what each step adds
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)
| Task | Command | Notes |
|---|---|---|
| Check someone's effective permission | gh api repos/OWNER/REPO/collaborators/USER/permission | role_name is the true role; permission is the legacy mapping (maintain→write, triage→read) |
| List collaborators | gh api repos/OWNER/REPO/collaborators --jq '.[] | [.login, .role_name] | @tsv' | affiliation=outside|direct|all |
| Invite an outside collaborator | gh api -X PUT repos/ORG/REPO/collaborators/USER -f permission=triage | permission: pull,triage,push,maintain,admin or a custom role name |
| Create team / child team | gh api orgs/ORG/teams -f name=backend -f privacy=closed -F parent_team_id=ID | A secret team cannot have a parent team |
| Grant a team a repository role | gh api -X PUT orgs/ORG/teams/backend/repos/ORG/REPO -f permission=push | Same permission values as above |
| Invite a member / join a team | gh api -X PUT orgs/ORG/memberships/USER -f role=member; gh api -X PUT orgs/ORG/teams/backend/memberships/USER | the invitee needs to accept the invitation |
| Set base permissions | gh api -X PATCH orgs/ORG -f default_repository_permission=read | Requires organization owner |
| Change visibility | gh repo edit ORG/REPO --visibility private --accept-visibility-change-consequences | Requires Admin; changing public → private loses stars/watches, etc. |
| Transfer a personal repository to an organization | gh api repos/USER/REPO/transfer -f new_owner=ORG | Old 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)
myorg-lab/myapp. Learners without an organization can read along and complete step 5 on a personal repository.ORG=myorg-lab gh api -X PATCH orgs/$ORG -f default_repository_permission=read --jq .default_repository_permission
read
https://github.com/orgs/myorg-lab/teams (backend appears under engineering).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"}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.
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
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.
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
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
No verified video specifically explaining organization roles and team nesting was found; follow the official documentation below and the storyboard script.
Official documentation
- Repository roles for an organization(full permissions table)
- Setting base permissions
- About organization teams
- About custom repository roles (GHEC)
- Permission levels for a personal account repository
Video storyboard script (about 100 seconds)
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.
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”.
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.
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.
Module 3 · Issues, Projects and Discussions
- 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).
What: three tools, three kinds of information
| Issues | Projects | Discussions | |
|---|---|---|---|
| Nature | Trackable work items in a repository (bugs, tasks, features) | Cross-repository planning views (table / board / roadmap), owned by users or organizations | Open-ended conversations (Q&A, ideas, announcements, polls) |
| Status | open / 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 for | work that is “decided to be done” | scheduling, tracking progress, cross-team roadmaps | things “not yet decided whether to do”; community support |
| Conversion | issues ↔ 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 issuewill 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
| Scenario | What 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 repositories | Parent issue (feature) + cross-repository sub-issues |
| Iteration planning every two weeks | Project's Iteration field + a board grouped by iteration |
Comparison with similar tools
| GitHub Issues + Projects | Jira | Azure Boards | |
|---|---|---|---|
| Distance from code | Same platform; closing keywords and the Development sidebar link natively | Via integrations (Smart Commits, etc.) | Native in Azure Repos; GitHub integrates via AB#123 |
| Process customization | Lightweight: fields + views + workflows | Strong: workflow schemes, permission schemes | Process templates (Agile/Scrum/CMMI) |
| Hierarchy | Sub-issues (8 levels) | Epic → Story → Sub-task (extensible) | Epic → Feature → PBI → Task |
Data model: issues, sub-issues, Project items and PRs
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.
Core commands
| Command | Purpose | Key parameters |
|---|---|---|
gh label create / list / clone | Manage 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 create | Create issue | -t,-b,-l,-a @me,-m,--parent N,-p "project name" |
gh issue edit | Edit | --add-label,--add-sub-issue N,M,--remove-parent |
gh issue list | Filter list | -l bug -a @me -s open --search "sort:updated-desc" |
gh issue close | Close | --reason completed|"not planned",-c "comment" |
gh project create / item-add / field-create / item-list | Manage Projects | Requires a token with the project scope: gh auth refresh -s project |
gh repo edit --enable-discussions | Enable Discussions | Requires 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)
--owner myorg-lab to create the project).Parent issue .is:issue,pr is:open, choose the repository myapp).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 …
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.
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
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
Official documentation
- Adding sub-issues
- Managing issue types
- About Projects
- Using the built-in automations
- Linking a pull request to an issue
- About discussions
- Changelog 2025-04-08: Evolving GitHub Issues and Projects
Video storyboard script (about 90 seconds)
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.
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.
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.
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.
Module 4 · Pull request end-to-end workflow
- 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.
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
| Stage | Platform behaviour | Key points |
|---|---|---|
| Draft PR | CI can run, but it cannot be merged, code owners are not automatically requested for review | suitable for sharing progress early; gh pr create --draft,gh pr ready switching to ready for review (code owners are requested at this point) |
| Request review | The requester needs Write; you can request individuals or teams who have Read on the repository | Large teams can enable automatic assignment (code review assignment) to avoid notifying everyone |
| Review | Three outcomes: Comment, Approve, Request changes; anyone with Read can review | Only Write or above approvals / change requests count toward “required reviews” |
| Suggested changes | inserts 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 checks | Actions or external CI writes results back via the Checks / Statuses API | Required 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 evaluation | Aggregates all applicable rulesets and branch protection,taking the strictest | if not met, the merge button is greyed out and the reasons are listed |
| Merge | Requires 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 commit | Squash and merge | Rebase and merge | |
|---|---|---|---|
| Git equivalent | git merge --no-ff | Squashes all of the PR's commits into one new commit and fast-forwards onto base | Replays each commit onto base one by one, then fast-forwards |
| Adds to base | the original commits (SHAs unchanged) + 1 merge commit | 1 new commit | N new SHAs commits |
| History shape | Non-linear (preserves branch topology) | Linear, one commit per PR | Linear, keeps each commit |
| Author information | Preserved | A single commit after squashing (Co-authored-by records multiple authors) | Author preserved; GitHub always updates the committer and generates new SHAs |
| Signatures | Original commit signatures are kept; the merge commit is signed by GitHub | GitHub signs the new commit | Replayed 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 recur | Drops commits that were already empty (unlike local git rebase ) |
| Suitable for | Needing full branch history, release branch merges | Most 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.
Sequence diagram: the platform event flow of one PR
How the three merge methods affect the commit graph
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.
Core commands
| Command | Purpose | Key parameters |
|---|---|---|
gh pr create | Create 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 --undo | Draft ↔ ready for review | Request code owners when converting to ready |
gh pr checkout N | Check out someone else's PR locally | actually fetches refs/pull/N/head |
gh pr diff / gh pr view --comments | View before reviewing | --name-only,--web |
gh pr review | Submit review | --approve,--request-changes -b,--comment -b |
gh pr checks | View checks | --watch,--required,--fail-fast |
gh pr update-branch | Merge base (or --rebase) into head | used when “require branches to be up to date” is on |
gh pr merge | Merge | -m/-s/-r,--auto,--disable-auto,-d (delete branch),--match-head-commit SHA,--admin (bypass requirements; requires permission) |
gh pr view --json mergeStateStatus,mergeable,reviewDecision | Why it cannot be merged | see 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)
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"}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
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
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
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).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.
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.
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"
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
Official documentation
- About pull requests
- About pull request reviews
- About merge methods on GitHub
- Automatically merging a pull request
- Troubleshooting required status checks
- About rulesets
Video storyboard script (about 120 seconds)
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.
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.
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.
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.
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.
Module 5 · gh CLI and REST / GraphQL API
- Understand gh authentication and configuration (credential store,
GH_TOKEN,GH_HOST, multiple accounts), and use fluentlygh repo,gh issue,gh pr,gh runand--json/--jqoutput. - Use
gh apito call REST (placeholders,-f/-F,--method,--paginate/--slurp) and GraphQL (variables,$endCursorpagination). - Know the criteria for choosing between REST and GraphQL, the API version header, and the values and handling of primary and secondary rate limits.
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:
--paginateautomatically follows REST'sLinkheader or GraphQL'spageInfo. - CI-friendly: set in Actions
GH_TOKEN: ${{ github.token }}to use it (Lesson 2).
How: authentication model
| Method | Suitable for | Notes |
|---|---|---|
gh auth login (browser device code) | Developer's local machine | The 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.txt | No-browser environment | Official 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 method | takes priority over stored credentials; for GHE hosts use GH_ENTERPRISE_TOKEN |
--expiring | wants tokens to expire and refresh automatically | A 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) | |
|---|---|---|
| Model | Resources + HTTP verbs; each endpoint returns a fixed structure | A single endpoint; the client precisely declares the fields and relations it needs |
| Suitable for | Simple CRUD, Actions, rulesets, webhooks and other features offered only by REST | Fetching multiple levels of related data at once (PR + reviews + checks + linked issues), Projects (the newer Projects API is GraphQL) |
| Pagination | per_page (usually a maximum of 100) + Link: <…>; rel="next" | cursor: first: 100, after: $endCursor + pageInfo { hasNextPage endCursor } |
| Version | X-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 released | No versioning; evolves by schema changes and deprecation notices |
| Primary rate limit | Unauthenticated 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/hour | Measured 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 apiuse REST. - Need to fetch a lot of related data at once or operate on Projects →
gh api graphqluse GraphQL. - Long-running services or organization-level automation → GitHub App (higher limits, fine-grained, not dependent on a personal account; Lessons 5 and 7).
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
gh command map
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.
gh subcommand overview
| Command | Purpose | Common parameters |
|---|---|---|
gh auth login / status / switch / refresh / token / logout | Authentication 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 / sync | Repositories | --template,--source . --push,--json,gh repo fork --clone |
gh issue list / create / view / edit / close / develop | issue | gh issue develop N --checkout create a linked branch |
gh pr create / list / view / checkout / review / merge / checks | PRs (Module 4) | --json,--web |
gh run list / view / watch / rerun / download | Actions runs | gh run view --log-failed,gh run rerun --failed |
gh search repos / issues / prs / code | search (Module 7) | --owner,--language,--json |
gh alias set / gh extension install | extensions for gh | gh alias set prs 'pr list --author @me' |
gh api ENDPOINT | any 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)
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.
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.
closingIssuesReferences includes the issue from Module 3.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.
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)
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'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
Official documentation
- GitHub CLI manual(gh api,gh auth login)
- cli/cli releases (v2.104.0)
- Rate limits for the REST API
- Rate limits and query limits for the GraphQL API
- REST API versions
- GraphQL Explorer
Video storyboard script (about 100 seconds)
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.
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.
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.
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.
Module 6 · Markdown, templates and repository community files
- 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.githubrepository of the organization or personal account provides default files; which files cannot be provided by the default repository.
What: GitHub Flavored Markdown (GFM)
| Syntax | Written as | Use |
|---|---|---|
| Task list | - [ ] write tests / - [x] done | PR 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/team | cross-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, ```suggestion | syntax highlighting and suggested changes |
| Diagrams | ```mermaid (flowcharts, sequence diagrams, pie charts, etc.), and geojson,topojson,stl | rendering in issues, discussions, PRs, wikis and Markdown files |
| Math | $E=mc^2$,$$ … $$ | formulas |
| Permalinks | While browsing a file, press y to expand the URL into the canonical form with the commit SHA | Reference 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
| File | Purpose | Location | Can be defaulted by the .github repository? |
|---|---|---|---|
| README.md | Project 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.md | How to contribute; a link is shown when opening an issue or PR | Same three locations as above | Yes |
| CODE_OF_CONDUCT.md | Community code of conduct | Same as above | Yes |
| SECURITY.md | How to report vulnerabilities (used together with private vulnerability reporting and security advisories) | Same as above | Yes |
| SUPPORT.md | Where to get help | Same as above | Yes |
| FUNDING.yml | Shows the Sponsor button | .github/ | Yes |
| Issue templates / forms + config.yml | Structured 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 template | Default content of the PR description | pull_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 URL | Yes |
| Discussion category forms | Templates for new discussions | .github/DISCUSSION_TEMPLATE/ | Yes |
| CODEOWNERS | Automatically 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. |
| LICENSE | License | Root directory | No: 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
.githubas 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.githubrepository'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) | |
|---|---|---|
| Experience | Pre-filled text; submitters can delete all of it | Web form: input boxes, text areas, dropdowns, checkboxes; can be set as required |
| Result | Used as-is as the issue body | Each field's answer is converted to Markdown and written into the body |
| Metadata | front matter: name,about,title,labels,assignees | Top level: name,description,title,labels,assignees,projects,body is an array of fields |
| Applies to | Issues 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.
.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
Issue forms from YAML to issue 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.
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)
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
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.
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”.
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.
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_percentageThe 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
Official documentation
- Basic writing and formatting syntax(including alerts)
- Creating diagrams (Mermaid)
- Syntax for issue forms
- Creating a default community health file
- About code owners
Video storyboard script (about 90 seconds)
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.
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.
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.
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.
Module 7 · Notifications, search and productivity
- 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.
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
| Level | What you receive | Suitable for |
|---|---|---|
| Participating and @mentions | Only participating conversations | Default recommendation; most repositories |
| All Activity | All activity in the repository | A few repositories you maintain |
| Custom | Participating + selected events: Issues, Pull requests, Releases, Discussions, Security alerts | Dependency projects where you only follow releases |
| Ignore | Nothing (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:donecan 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 search | REST code search API / gh search code | |
|---|---|---|---|
| qualifiers | repo: org: user: language: path: symbol: content: is:archived is:fork is:vendored is:generated | is:open is:pr author: assignee: label: review-requested: involves: draft: review: sort: | Legacy code search syntax (legacy),does not support regex and symbol: |
| advanced capabilities | Regex /sparse.*index/,AND/OR/NOT, parentheses, exact phrases "...",path: Supports glob (*,**) | no:assignee,-label:wontfix (exclusion), date ranges updated:>2026-11-01 | subject to a dedicated per-minute rate limit |
| Requirement | Requires sign-in | — | Requires authentication |
Common search recipes
| Purpose | Query |
|---|---|
| PRs awaiting my review | is:pr is:open review-requested:@me archived:false |
| All open conversations I have participated in | is:open involves:@me sort:updated-desc |
| My PRs with failing checks | is:pr is:open author:@me status:failure |
| Who in the organization still uses a certain function | org: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 SHA | org: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
- Default Watch = Participating; All Activity only for repositories you maintain; dependency projects Custom → Releases.
- Process the inbox twice a day: first
reason:review-requested, thenreason:mention, and mark the rest Done in bulk. - Bookmark a few search URLs (PRs awaiting my review, my failing PRs, conversations I'm in), or turn them into gh aliases.
- Turn common replies into saved replies (thanks for contributing, please add reproduction steps, duplicate issue).
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
Structure of a code search query
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.
Commands and API
| Command | Purpose | Notes |
|---|---|---|
gh api notifications | List unread notifications | -f all=true,-f participating=true (GET needs --method GET) |
gh api -X PUT notifications | Mark all as read | can take -f last_read_at=… |
gh api -X PUT repos/O/R/subscription -F subscribed=true | Watch repository (All Activity) | -F ignored=true for Ignore; DELETE Unsubscribe |
gh search prs / issues / repos | Search | --review-requested=@me,--state open,--json |
gh search code | Code search (API, legacy syntax) | --repo,--language,--filename,--extension |
gh status | Cross-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)
👀 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
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.
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 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
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.
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
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
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
- Configuring notifications
- Inbox filters
- Understanding GitHub Code Search syntax
- Searching issues and pull requests
- About saved replies
- Keyboard shortcuts
Video storyboard script (about 90 seconds)
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.
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.
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.
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.
Module 8 · Collaboration readiness review and introductory troubleshooting
- 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.
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:
| Category | Checks | Source module |
|---|---|---|
| Access control | Organization base permission Read or None; grant by team; Admin ≤ 3 people; outside collaborators reviewed periodically; organization requires 2FA | M2 |
| Branch protection | main has a ruleset: require PR (≥1 approval, dismiss old approvals), required checks, conversations resolved, block force pushes and deletions | M4 |
| Merge settings | Enable only the merge methods the team has agreed on (e.g. squash only); automatically delete branches after merging; allow auto-merge | M4 |
| Community files | README, CONTRIBUTING, PR template, issue forms + config.yml, CODEOWNERS (error-free), SECURITY.md, LICENSE (public repositories) | M6 |
| Planning | Label system, issue types, milestones or a Project; Discussions handle Q&A (optional) | M3 |
| Security and automation | CI 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
- Identity: who am I?
gh auth status,gh api user --jq .login,git config credential.helper, environment variablesGH_TOKEN. - Host: where is the request going? github.com,
*.ghe.comor GHES?git remote -v,GH_HOST. - Permission: what role do I have on this resource?
collaborators/USER/permission; token scopes or fine-grained permissions; whether SAML SSO is authorized. - Rules: which rulesets, branch protection or enterprise policies apply to it?
rules/branches/main; greyed-out settings. - Status: the PR's
mergeStateStatus, check results,githubstatus.com platform status.
Quick reference for HTTP status codes
| Status code | Typical meaning on GitHub | What to check first |
|---|---|---|
| 401 Bad credentials | Token invalid, expired or revoked | gh auth status, leftover GH_TOKEN |
| 403 Forbidden | Identity valid but permissions insufficient; token lacks scope; SAML SSO not authorized; rate limit; rejected by rules | the full response message,x-ratelimit-remaining, role |
| 404 Not Found | Resource 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 Conflict | State conflict, such as the head changing during a merge or an empty repository | Re-fetch the latest state |
| 422 Unprocessable | Parameter validation failed, PR not mergeable, duplicate creation | the errors array in the response |
| 429 / 403 + rate limit | Primary or secondary rate limit | retry-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).
gh auth setup-git.Troubleshooting order: from identity to status
Readiness review radar
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
| Problem | Command |
|---|---|
| Who am I / token scopes | gh auth status; gh api -i user | grep -i x-oauth-scopes |
| which credential git uses | git config --show-origin --get-all credential.helper; GIT_TRACE=1 git ls-remote origin 2>&1 | grep -i credential |
| my role on the repository | gh api repos/O/R --jq .permissions; …/collaborators/ME/permission --jq .role_name |
| rules applying to the branch | gh api repos/O/R/rules/branches/main |
| why a PR cannot be merged | gh pr view N --json mergeStateStatus,mergeable,reviewDecision,statusCheckRollup |
| Rate limit | gh api rate_limit --jq .resources.core |
| Platform status | githubstatus.com(also available as RSS/API) |
Lab 8: run a readiness review on myapp and fix it (about 7 min)
~/gh-readiness.sh:
bash ~/gh-readiness.sh $(gh repo view --json nameWithOwner --jq .nameWithOwner)
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.)
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
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.
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.).
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
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
No verified video specifically explaining the five-step GitHub platform troubleshooting method was found; the official documentation and storyboard script below apply.
Official documentation
- Troubleshooting the REST API
- Troubleshooting SSH
- Troubleshooting required status checks
- About community profiles
- GitHub Status
Video storyboard script (about 90 seconds)
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.
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?
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.
Command cheat sheet
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_URLPull 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 listNotifications 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
| Item | Value (docs.github.com, 2026-11-15) |
|---|---|
| REST primary limit | Unauthenticated 60/hour; users 5,000/hour; GITHUB_TOKEN 1,000/hour/repository (GHEC 15,000); GHEC organization App 15,000/hour |
| GraphQL primary limit | users 5,000 points/hour; GHEC organization App installations 10,000 points/hour; GITHUB_TOKEN 1,000 points/hour/repository |
| Secondary limit | 100 concurrent; REST 900 points/minute, GraphQL 2,000 points/minute; content creation generally 80/minute, 500/hour |
| Repository roles | Read · Triage · Moderate · Write · Maintain · Admin; custom repository roles GHEC only |
| Issues / Projects | Sub-issues: 100 per parent, 8 levels; issue types up to 25; project fields 50, items 50,000 |
| Free accounts | Public 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 residency | GHE.com: EU / Australia / US / Japan, EMU only, no public repositories |
Integrated lab + completion quiz
/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.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
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"
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.
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 .
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
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"}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"}]}}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".
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
| Topic | Verification result | Source (accessed 2026-11-15) |
|---|---|---|
| gh CLI version and installation | Latest 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.com | cli/cli releases · install_linux.md |
| gh command parameters | gh 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.83 | cli.github.com/manual |
| Plans and products | Free: 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 purchase | GitHub's plans · About GHAS |
| Data residency and GHES | GHE.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 plans | Free, Student, Pro, Pro+, Max (individual); Business, Enterprise (organization/enterprise); not available on GHES | Plans for GitHub Copilot |
| Permission model | Six 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 collaborator | Repository roles · Base permissions · About teams |
| Issues and Projects | Sub-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-04 | Sub-issues · Issue types · Built-in automations · Changelog 2025-04-08 |
| Pull requests | drafts 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 immediately | About PRs · Merge methods · Required checks · Auto-merge |
| Ruleset REST parameters | allowed_merge_methods,required_review_thread_resolution,require_last_push_approval,strict_required_status_checks_policy,~DEFAULT_BRANCH; up to 75 rulesets per repository | REST: Rules · About rulesets |
| API rate limits and versions | REST: 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 header | REST rate limits · GraphQL limits · API versions |
| Community files | Default 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/STL | Default community health files · About code owners · Issue forms · Diagrams |
| Notifications, search, productivity | Inbox 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 list | Inbox filters · Code search syntax · Legacy code search · Keyboard shortcuts |
| GitHub.com metadata | gh api meta 's SSH fingerprints and IP range count were measured on 2026-11-15 | api.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 metafingerprints and counts, and the gh--jsonfield 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.