GitHub has evolved far beyond Git hosting. Today it's a complete development platform with cloud development environments, AI coding assistance, project management, package hosting, and more. This guide covers GitHub's advanced features that can transform your development workflow.
GitHub Codespaces
Codespaces provides cloud-hosted development environments—full VS Code in your browser or local VS Code connected to a cloud VM.
┌─────────────────────────────────────────────────────────────┐
│ CODESPACES ARCHITECTURE │
├─────────────────────────────────────────────────────────────┤
│ │
│ Your Browser/VS Code │
│ │ │
│ │ WebSocket connection │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ GitHub Cloud │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ Codespace VM │ │ │
│ │ │ ┌──────────────────────────────────────┐ │ │ │
│ │ │ │ VS Code Server │ │ │ │
│ │ │ │ ├── Extensions │ │ │ │
│ │ │ │ ├── Language servers │ │ │ │
│ │ │ │ └── Terminal │ │ │ │
│ │ │ └──────────────────────────────────────┘ │ │ │
│ │ │ ┌──────────────────────────────────────┐ │ │ │
│ │ │ │ Your Repository (cloned) │ │ │ │
│ │ │ │ Docker, Node, Python, etc. │ │ │ │
│ │ │ └──────────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Creating a Codespace
# From GitHub.com
# 1. Navigate to repository
# 2. Click "Code" button
# 3. Select "Codespaces" tab
# 4. Click "Create codespace on main"
# From GitHub CLI
gh codespace create --repo owner/repo
# List your codespaces
gh codespace list
# Open in VS Code
gh codespace code --codespace <name>
Dev Container Configuration
Create .devcontainer/devcontainer.json:
{
"name": "Node.js Development",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-azuretools.vscode-docker",
"GitHub.copilot"
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
},
"forwardPorts": [3000, 5432],
"postCreateCommand": "npm install",
"postStartCommand": "npm run dev",
"remoteUser": "node"
}
Custom Dockerfile
.devcontainer/Dockerfile:
FROM mcr.microsoft.com/devcontainers/javascript-node:20
# Install additional tools
RUN apt-get update && apt-get install -y \
postgresql-client \
redis-tools \
&& rm -rf /var/lib/apt/lists/*
# Install global npm packages
RUN npm install -g pnpm turbo
# Pre-install dependencies for faster startup
WORKDIR /workspaces
COPY package*.json ./
RUN npm ci
.devcontainer/devcontainer.json:
{
"name": "Custom Environment",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
}
}
Codespace Prebuilds
Speed up Codespace creation with prebuilds:
- Go to Settings > Codespaces > Set up prebuilds
- Configure triggers (push to main, configuration changes)
- Prebuilds run in background, ready when you create Codespace
GitHub Copilot
Copilot is an AI pair programmer that suggests code in real-time.
Installation
- Subscribe at github.com/features/copilot
- Install extension:
- VS Code: "GitHub Copilot" extension
- JetBrains: "GitHub Copilot" plugin
- Neovim: copilot.vim
Usage Patterns
Inline completions:
// Type a comment describing what you want
// Function to calculate the nth Fibonacci number
function fibonacci(n: number): number {
// Copilot suggests the implementation
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
Generate tests:
// Write: "test for fibonacci function"
describe('fibonacci', () => {
it('returns 0 for input 0', () => {
expect(fibonacci(0)).toBe(0);
});
it('returns 1 for input 1', () => {
expect(fibonacci(1)).toBe(1);
});
it('returns 55 for input 10', () => {
expect(fibonacci(10)).toBe(55);
});
});
Generate documentation:
/**
* Type this and let Copilot complete:
* Calculates the nth Fibonacci number using recursion.
* @param n - The position in the Fibonacci sequence
* @returns The Fibonacci number at position n
* @example fibonacci(10) // returns 55
*/
Copilot Chat
Copilot Chat provides conversational AI in your editor:
/explain - Explain selected code
/fix - Suggest a fix for problems
/tests - Generate tests for code
/docs - Generate documentation
@workspace - Ask about entire codebase
Keyboard Shortcuts
| Action | macOS | Windows/Linux |
|---|---|---|
| Accept suggestion | Tab | Tab |
| Reject suggestion | Esc | Esc |
| Next suggestion | Option+] | Alt+] |
| Previous suggestion | Option+[ | Alt+[ |
| Open Copilot panel | Ctrl+Enter | Ctrl+Enter |
GitHub Projects
Projects is GitHub's project management tool with boards, tables, and roadmaps.
Project Views
┌─────────────────────────────────────────────────────────────┐
│ PROJECT VIEWS │
├─────────────────────────────────────────────────────────────┤
│ │
│ BOARD VIEW (Kanban) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Todo │ │In Progress│ │ Review │ │ Done │ │
│ ├──────────┤ ├──────────┤ ├──────────┤ ├──────────┤ │
│ │ Issue #1 │ │ Issue #3 │ │ Issue #5 │ │ Issue #7 │ │
│ │ Issue #2 │ │ Issue #4 │ │ │ │ Issue #8 │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
│ │
│ TABLE VIEW (Spreadsheet) │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Title │ Status │ Assignee │ Sprint │ Points │ │
│ ├────────────┼───────────┼──────────┼────────┼────────┤ │
│ │ Issue #1 │ Todo │ @alice │ Sprint1│ 3 │ │
│ │ Issue #2 │ In Progress│ @bob │ Sprint1│ 5 │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ROADMAP VIEW (Timeline) │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Jan Feb Mar Apr │ │
│ │ ═══════════ │ │
│ │ Feature A │ │
│ │ ═══════════════ │ │
│ │ Feature B │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Custom Fields
Add custom fields to track anything:
| Field Type | Usage |
|---|---|
| Text | Notes, descriptions |
| Number | Story points, estimates |
| Date | Due dates, deadlines |
| Single select | Status, priority, type |
| Iteration | Sprints, milestones |
Automation
Built-in automations:
# Auto-set status when PR is merged
When: Pull request is merged
Then: Set Status to "Done"
# Auto-add items from issues
When: Issue is added to project
Then: Set Status to "Todo"
# Auto-archive completed items
When: Status changes to "Done"
Then: Archive item after 14 days
Project Insights
Track project metrics:
- Burn-up/burn-down charts
- Items by status over time
- Assignee workload
- Sprint velocity
GitHub Discussions
Discussions provides community forums within repositories.
Discussion Categories
| Category | Icon | Purpose |
|---|---|---|
| Announcements | 📣 | Team/maintainer broadcasts |
| General | 💬 | Open conversation |
| Ideas | 💡 | Feature suggestions |
| Polls | 📊 | Community voting |
| Q&A | 🙋 | Questions with marked answers |
| Show and tell | 🙌 | Project showcases |
Enabling Discussions
Settings > Features > Discussions
Best Practices
ISSUES DISCUSSIONS
────── ───────────
• Bugs to fix • "How do I...?" questions
• Feature requests (confirmed) • Feature brainstorming
• Tasks with clear scope • Announcements
• Actionable work items • Community chat
• Polls and feedback
Convert Discussion to Issue:
- Click "Create issue from discussion" when action is decided
GitHub Packages
Packages provides registry hosting for npm, Docker, Maven, NuGet, and more.
Publishing npm Package
.npmrc:
@myorg:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
package.json:
{
"name": "@myorg/my-package",
"version": "1.0.0",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}
Publish:
# Login
npm login --registry=https://npm.pkg.github.com
# Publish
npm publish
Publishing Docker Image
# Login to GitHub Container Registry
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# Tag image
docker tag my-image ghcr.io/myorg/my-image:latest
# Push
docker push ghcr.io/myorg/my-image:latest
GitHub Actions workflow:
name: Publish Docker
on:
release:
types: [published]
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
GitHub Pages
Pages hosts static websites directly from repositories.
Quick Setup
- Settings > Pages
- Source: Deploy from a branch
- Branch: main (or gh-pages) / root (or /docs)
- Site available at
username.github.io/repo
Custom Build with Actions
.github/workflows/pages.yml:
name: Deploy to Pages
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install and build
run: |
npm ci
npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to Pages
id: deployment
uses: actions/deploy-pages@v4
Custom Domain
- Add
CNAMEfile with your domain - Configure DNS:
- A records pointing to GitHub IPs
- Or CNAME to
username.github.io
# DNS records
A 185.199.108.153
A 185.199.109.153
A 185.199.110.153
A 185.199.111.153
# Or
CNAME username.github.io
GitHub CLI (gh)
The GitHub CLI brings GitHub to your terminal.
Installation
# macOS
brew install gh
# Windows
winget install GitHub.cli
# Linux
sudo apt install gh
Authentication
# Interactive login
gh auth login
# Check status
gh auth status
Common Commands
Pull Requests:
# Create PR
gh pr create --title "Feature" --body "Description"
# Create draft PR
gh pr create --draft
# List PRs
gh pr list
# View PR
gh pr view 123
# Check out PR locally
gh pr checkout 123
# Merge PR
gh pr merge 123 --squash
# Review PR
gh pr review 123 --approve
Issues:
# Create issue
gh issue create --title "Bug" --body "Description"
# List issues
gh issue list --label bug
# View issue
gh issue view 456
# Close issue
gh issue close 456
Actions:
# List workflow runs
gh run list
# View specific run
gh run view 789
# Watch run in progress
gh run watch
# Re-run failed jobs
gh run rerun 789 --failed
# Download artifacts
gh run download 789
Repository:
# Clone repo
gh repo clone owner/repo
# Create repo
gh repo create my-project --public
# Fork repo
gh repo fork owner/repo
# View repo in browser
gh repo view --web
Aliases
Create custom shortcuts:
# Add alias
gh alias set prc 'pr create --fill'
gh alias set prl 'pr list --author @me'
# Use alias
gh prc # Creates PR with auto-filled title/body
API Access
# Make API requests
gh api repos/owner/repo/issues
# POST request
gh api repos/owner/repo/issues -f title="New Issue" -f body="Details"
# GraphQL
gh api graphql -f query='{ viewer { login } }'
Feature Comparison
| Feature | Free | Pro | Team | Enterprise |
|---|---|---|---|---|
| Codespaces | 120 hrs/mo | 180 hrs/mo | 180 hrs/mo | Custom |
| Copilot | $10/mo add-on | $10/mo add-on | $19/user/mo | $39/user/mo |
| Projects | Unlimited | Unlimited | Unlimited | Unlimited |
| Discussions | ✓ | ✓ | ✓ | ✓ |
| Pages | Public repos | + Private | + Private | + Private |
| Packages | 500MB | 2GB | 2GB | 50GB |
Related Resources
- Git & GitHub Complete Guide - Hub for all Git guides
- GitHub Actions CI/CD - Workflow automation
- GitHub Repository Security - Security configuration
- GitHub Flavored Markdown - Markdown syntax