GitHub Lesson Plan
A progressive curriculum to master GitHub through hands-on practice.
Lesson 1: Repository Basics
Section titled “Lesson 1: Repository Basics”Goal: Create and configure repositories.
Concepts
Section titled “Concepts”GitHub hosts git repositories and adds collaboration features: issues, pull requests, actions, and more.
Exercises
Section titled “Exercises”-
Create a repository
Terminal window # On github.com: New repository# Or with gh CLI:gh repo create my-project --public --clonecd my-project -
Clone and configure
Terminal window git clone https://github.com/you/repo.gitcd repo# Or with SSH (recommended)git clone git@github.com:you/repo.git# Set up gh CLIgh auth logingh auth status -
Repository settings
Terminal window # View repo infogh repo view# Edit settingsgh repo edit --description "My awesome project"gh repo edit --visibility privategh repo edit --enable-issues=false -
Add essential files
Terminal window # README.md - project overview# LICENSE - usage terms (MIT, Apache, etc.)# .gitignore - files to exclude# CONTRIBUTING.md - how to contributegh repo view --web # Open in browser
Checkpoint
Section titled “Checkpoint”Create a repo with README, LICENSE, and .gitignore. Clone it locally.
Lesson 2: Issues
Section titled “Lesson 2: Issues”Goal: Track work with issues.
Concepts
Section titled “Concepts”Issues track bugs, features, and tasks. They’re the unit of work on GitHub.
Exercises
Section titled “Exercises”-
Create issues
Terminal window # Create issuegh issue create --title "Add user authentication" \--body "Implement login/logout functionality"# With labelsgh issue create --title "Fix navbar bug" \--label "bug" --label "priority:high"# Assign to yourselfgh issue create --title "Update docs" --assignee @me -
List and view issues
Terminal window gh issue listgh issue list --state opengh issue list --label "bug"gh issue list --assignee @megh issue view 123gh issue view 123 --web # Open in browser -
Update issues
Terminal window # Add commentgh issue comment 123 --body "Working on this now"# Close issuegh issue close 123# Reopengh issue reopen 123# Editgh issue edit 123 --add-label "in-progress"gh issue edit 123 --add-assignee @me -
Link issues to code
Terminal window # Reference in commit messagegit commit -m "Add login form (refs #123)"# Close via commitgit commit -m "Implement auth (fixes #123)"# Keywords: fixes, closes, resolves
Checkpoint
Section titled “Checkpoint”Create 3 issues with different labels. Close one via a commit message.
Lesson 3: Pull Requests
Section titled “Lesson 3: Pull Requests”Goal: Propose and review changes.
Concepts
Section titled “Concepts”Pull requests (PRs) propose merging one branch into another. They enable code review, discussion, and CI checks before merging.
Exercises
Section titled “Exercises”-
Create a PR
Terminal window # Create branch and make changesgit switch -c feature/add-search# ... make changes ...git add . && git commit -m "Add search functionality"git push -u origin feature/add-search# Create PRgh pr create --title "Add search" \--body "Implements search feature. Fixes #45"# Or interactivelygh pr create --fill # Uses commit messages -
List and view PRs
Terminal window gh pr listgh pr list --state allgh pr list --author @megh pr view 42gh pr view 42 --webgh pr diff 42 -
Review PRs
Terminal window # Check out PR locallygh pr checkout 42# Add reviewgh pr review 42 --approvegh pr review 42 --request-changes --body "Please fix X"gh pr review 42 --comment --body "Looks good overall"# Comment on specific linegh pr comment 42 --body "Consider using Y here" -
Merge and cleanup
Terminal window # Merge PRgh pr merge 42gh pr merge 42 --squash # Squash commitsgh pr merge 42 --rebase # Rebase commitsgh pr merge 42 --delete-branch # Delete after merge# Close without merginggh pr close 42
Checkpoint
Section titled “Checkpoint”Create a feature branch, open a PR, and merge it with squash.
Lesson 4: GitHub Actions Basics
Section titled “Lesson 4: GitHub Actions Basics”Goal: Automate workflows with CI/CD.
Concepts
Section titled “Concepts”Actions run automated workflows triggered by events (push, PR, schedule).
Workflows are YAML files in .github/workflows/.
Exercises
Section titled “Exercises”-
Create a basic workflow
.github/workflows/ci.yml name: CIon:push:branches: [main]pull_request:jobs:test:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4- name: Run testsrun: npm test -
View workflow runs
Terminal window gh run listgh run view 12345gh run view 12345 --loggh run watch # Live view of in-progress run -
Trigger and manage runs
Terminal window # Re-run failed jobsgh run rerun 12345# Cancel rungh run cancel 12345# Download artifactsgh run download 12345 -
Common patterns
# Matrix buildsjobs:test:strategy:matrix:node: [18, 20, 22]os: [ubuntu-latest, macos-latest]runs-on: ${{ matrix.os }}steps:- uses: actions/setup-node@v4with:node-version: ${{ matrix.node }}# Conditional steps- name: Deployif: github.ref == 'refs/heads/main'run: ./deploy.sh
Checkpoint
Section titled “Checkpoint”Create a workflow that runs tests on every PR and push to main.
Lesson 5: Advanced Actions
Section titled “Lesson 5: Advanced Actions”Goal: Build sophisticated CI/CD pipelines.
Exercises
Section titled “Exercises”-
Caching dependencies
- uses: actions/cache@v4with:path: ~/.npmkey: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}restore-keys: |${{ runner.os }}-node- -
Secrets and environment variables
jobs:deploy:runs-on: ubuntu-latestenv:NODE_ENV: productionsteps:- name: Deployenv:API_KEY: ${{ secrets.API_KEY }}run: ./deploy.shTerminal window # Manage secretsgh secret set API_KEYgh secret list -
Job dependencies
jobs:build:runs-on: ubuntu-lateststeps:- run: npm run buildtest:needs: buildruns-on: ubuntu-lateststeps:- run: npm testdeploy:needs: [build, test]if: github.ref == 'refs/heads/main'runs-on: ubuntu-lateststeps:- run: ./deploy.sh -
Reusable workflows
.github/workflows/reusable.yml on:workflow_call:inputs:environment:required: truetype: stringjobs:deploy:runs-on: ubuntu-lateststeps:- run: echo "Deploying to ${{ inputs.environment }}"# Calling workflowjobs:call-deploy:uses: ./.github/workflows/reusable.ymlwith:environment: production
Checkpoint
Section titled “Checkpoint”Create a workflow with build, test, and deploy jobs. Add caching for dependencies.
Lesson 6: Collaboration Features
Section titled “Lesson 6: Collaboration Features”Goal: Use GitHub’s collaboration tools effectively.
Exercises
Section titled “Exercises”-
Code owners
# .github/CODEOWNERS# Default owners* @team-leads# Specific paths/docs/ @docs-team*.js @frontend-team/api/ @backend-team @security-team -
Branch protection
Terminal window # Via gh CLI (limited)gh api repos/{owner}/{repo}/branches/main/protection \--method PUT \--field required_status_checks='{"strict":true,"contexts":["test"]}' \--field enforce_admins=true \--field required_pull_request_reviews='{"required_approving_review_count":1}'Key settings:
- Require PR reviews before merging
- Require status checks to pass
- Require branches to be up to date
- Include administrators
-
Templates
## <!-- .github/ISSUE_TEMPLATE/bug_report.md -->name: Bug Report about: Report a bug labels: bug---## Description## Steps to Reproduce1.2.3.## Expected Behavior## Actual Behavior.github/PULL_REQUEST_TEMPLATE.md ## Summary## Changes## Testing## Checklist- [ ] Tests added- [ ] Documentation updated -
Discussions and wikis
Terminal window # Enable discussionsgh repo edit --enable-discussions# Discussions are for:# - Q&A# - Ideas and feature requests# - Show and tell# - General conversation
Checkpoint
Section titled “Checkpoint”Add CODEOWNERS, issue template, and PR template to a repository.
Lesson 7: Releases and Packages
Section titled “Lesson 7: Releases and Packages”Goal: Publish releases and packages.
Exercises
Section titled “Exercises”-
Create releases
Terminal window # Create a taggit tag -a v1.0.0 -m "Version 1.0.0"git push origin v1.0.0# Create release from taggh release create v1.0.0 --title "v1.0.0" \--notes "First stable release"# With auto-generated notesgh release create v1.1.0 --generate-notes# Upload assetsgh release create v1.0.0 ./dist/app.zip ./dist/app.tar.gz -
List and manage releases
Terminal window gh release listgh release view v1.0.0gh release download v1.0.0# Edit releasegh release edit v1.0.0 --draft=false# Delete releasegh release delete v1.0.0 -
Automate releases
.github/workflows/release.yml on:push:tags:- "v*"jobs:release:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4- name: Buildrun: npm run build- name: Create Releaseuses: softprops/action-gh-release@v1with:files: dist/*generate_release_notes: true -
GitHub Packages
# Publish npm package- uses: actions/setup-node@v4with:registry-url: "https://npm.pkg.github.com"- run: npm publishenv:NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Checkpoint
Section titled “Checkpoint”Create a release with auto-generated notes and uploaded assets.
Lesson 8: GitHub API and Automation
Section titled “Lesson 8: GitHub API and Automation”Goal: Automate GitHub with the API.
Exercises
Section titled “Exercises”-
Using gh api
Terminal window # Get repo infogh api repos/{owner}/{repo}# List PRsgh api repos/{owner}/{repo}/pulls# Create issuegh api repos/{owner}/{repo}/issues \--method POST \--field title="New issue" \--field body="Description"# GraphQLgh api graphql -f query='query {viewer {loginrepositories(first: 10) {nodes { name }}}}' -
Webhooks
Terminal window # List webhooksgh api repos/{owner}/{repo}/hooks# Create webhookgh api repos/{owner}/{repo}/hooks \--method POST \--field name="web" \--field config='{"url":"https://example.com/webhook","content_type":"json"}' \--field events='["push","pull_request"]' -
GitHub Apps and tokens
# Using GITHUB_TOKEN in Actions- name: Create issueuses: actions/github-script@v7with:script: |await github.rest.issues.create({owner: context.repo.owner,repo: context.repo.repo,title: 'Automated issue',body: 'Created by workflow'}) -
Automation scripts
#!/bin/bash# Close stale issuesgh issue list --label "stale" --json number --jq '.[].number' | \while read -r num; dogh issue close "$num" --comment "Closing stale issue"doneTerminal window # Bulk label PRsgh pr list --json number --jq '.[].number' | \while read -r num; dogh pr edit "$num" --add-label "needs-review"done
Checkpoint
Section titled “Checkpoint”Write a script that lists all open PRs older than 7 days and adds a “stale” label.
Practice Projects
Section titled “Practice Projects”Project 1: Open Source Ready
Section titled “Project 1: Open Source Ready”Prepare a repository for open source:
- README with badges
- Contributing guidelines
- Issue and PR templates
- CI workflow with tests and linting
- Branch protection rules
Project 2: Release Automation
Section titled “Project 2: Release Automation”Set up automated releases:
- Semantic versioning
- Changelog generation
- Build artifacts
- Publish to GitHub Packages
Project 3: Team Workflow
Section titled “Project 3: Team Workflow”Configure a team repository:
- CODEOWNERS for different areas
- Required reviewers
- Status checks
- Automated labeling
Command Reference
Section titled “Command Reference”| Task | Command |
|---|---|
| Create repo | gh repo create |
| Clone repo | gh repo clone owner/repo |
| Create issue | gh issue create |
| Create PR | gh pr create |
| Merge PR | gh pr merge |
| View runs | gh run list |
| Create release | gh release create |
| API call | gh api <endpoint> |
See Also
Section titled “See Also”- Git Lesson Plan — Git fundamentals
- Git Cheatsheet — Quick command reference
- CI/CD