From repositories and pull requests to CI/CD pipelines and the GitHub CLI
gh) for terminal-driven workflowsGitHub is the world's largest source code hosting platform, built on top of Git. It adds collaboration, code review, project management, CI/CD, and security tooling around Git's distributed version control.
GitHub is not Git. You can use Git without GitHub, and GitHub without the command line (though you shouldn't).
A repository (repo) is a project — source code, history, branches, issues, and settings in one place.
| File | Purpose |
|---|---|
README.md | Project overview — rendered on the repo homepage |
LICENSE | Legal terms for using the code |
.gitignore | Patterns for files Git should not track |
CONTRIBUTING.md | Guidelines for contributors |
CODEOWNERS | Auto-assign reviewers based on file paths |
.github/ | Actions workflows, issue templates, PR templates |
GitHub uses GitHub Flavoured Markdown (GFM) — standard Markdown extended with tables, task lists, syntax-highlighted code blocks, and auto-linked references.
# Heading 1
## Heading 2
### Heading 3
**bold** and *italic* and `inline code`
- bullet list
- [ ] task list (unchecked)
- [x] task list (checked)
[Link text](https://example.com)

| Column A | Column B |
|----------|----------|
| cell | cell |
#123 — auto-links to issue or PR number 123@username — mentions a user (sends notification):emoji_name: — renders emoji<details> — collapsible sectionsREADMEs, issues, PRs, comments, wikis, GitHub Pages, release notes, discussion posts, and profile READMEs (username/username repo).
A pull request (PR) is GitHub's mechanism for proposing, reviewing, and merging changes. It is the central unit of collaboration.
Open a PR as Draft to signal work-in-progress. CI still runs, but reviewers know it is not ready.
| Strategy | Result | When to use |
|---|---|---|
| Merge commit | Preserves all commits + merge commit | Full history matters |
| Squash and merge | One commit on main | Default for most teams |
| Rebase and merge | Replays commits onto main | Linear history purists |
Code review is the highest-leverage quality practice a team can adopt. GitHub's review tools make it structured and asynchronous.
Click any line in the diff to leave a comment. Use suggestions to propose exact code changes the author can accept with one click:
```suggestion
const result = items.filter(Boolean);
```
# .github/CODEOWNERS
*.js @frontend-team
*.py @backend-team
docs/ @tech-writers
*.tf @infra-team
.github/ISSUE_TEMPLATE/bug_report.md or YAML formsFixes #42 in the PR descriptionUse labels to categorise: bug, enhancement, documentation, good first issue, priority:high. Group issues into milestones with a due date and progress bar.
# .github/ISSUE_TEMPLATE/bug_report.yml
name: Bug Report
description: Report a bug
body:
- type: input
id: version
attributes:
label: Version
validations:
required: true
GitHub Actions is GitHub's built-in CI/CD and automation platform. Workflows are YAML files in .github/workflows/.
| Concept | Description |
|---|---|
| Workflow | A YAML file defining an automated process |
| Event / Trigger | What starts the workflow (push, pull_request, schedule) |
| Job | A set of steps on a single runner |
| Step | A single task — shell command or reusable Action |
| Runner | The VM or container executing the job |
| Action | Reusable, packaged step from the Marketplace |
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 6 * * 1' # Monday 06:00
workflow_dispatch: # manual trigger
release:
types: [published]
ubuntu-latest, windows-latest, macos-latest# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
lint-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm test -- --coverage
build:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
needs: — declare job dependenciesstrategy.matrix — run across multiple configsif: — conditionally run a step or jobenv: — environment variables at any levelsecrets.* — encrypted secrets${{ github.sha }} — expression contextUnlimited Actions minutes for public repos. Private repos get 2,000 minutes/month on the Free plan.
Define a workflow in one repo, call it from others. DRY for organisation-wide CI standards.
jobs:
deploy:
uses: my-org/shared/.github/
workflows/deploy.yml@main
with:
environment: production
secrets: inherit
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles(
'**/package-lock.json') }}
restore-keys: npm-
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
Prevents duplicate runs — new commit cancels old run.
staging, production) in settingsThe GitHub CLI (gh) brings GitHub to the terminal. It replaces switching to the browser for PRs, issues, Actions, and more.
# macOS
brew install gh
# Ubuntu / Debian
sudo apt install gh
# Windows
winget install GitHub.cli
gh auth login
gh auth status
gh auth switch
gh repo create my-app \
--public --clone
gh repo clone owner/repo
gh repo fork owner/repo \
--clone
gh repo view owner/repo \
--web
gh repo list my-org \
--limit 50
gh pr create --title "Add X" \
--body "Description"
gh pr list --state open
gh pr checkout 42
gh pr review 42 --approve
gh pr merge 42 --squash \
--delete-branch
gh pr checks 42
gh issue create \
--title "Bug" --label bug
gh issue list --assignee @me
gh issue close 99
gh run list
gh run view 123456
gh run watch 123456
gh run rerun 123456
gh workflow list
gh workflow run deploy.yml
gh workflow run deploy.yml \
-f env=staging
# Get repo info
gh api repos/owner/repo
# List PR comments
gh api repos/owner/repo/\
pulls/42/comments
# Create a label
gh api repos/owner/repo/labels \
-f name="priority:critical" \
-f color="d73a4a"
# Create a custom alias
gh alias set prs \
'pr list --state open \
--assignee @me'
gh prs # now works
# Install community extensions
gh extension install \
dlvhdr/gh-dash
gh extension install \
github/gh-copilot
# Close all wontfix issues
gh issue list --label "wontfix" \
--json number \
--jq '.[].number' \
| xargs -I {} gh issue close {}
# Create PRs across repos
for repo in api web worker; do
gh pr create \
--repo "my-org/$repo" \
--title "Bump deps"
done
Free static site hosting directly from a repository.
main, gh-pages, or /docsusername.github.io/repo-name# .github/workflows/pages.yml
name: Deploy to Pages
on:
push:
branches: [main]
permissions:
pages: write
id-token: write
jobs:
deploy:
environment:
name: github-pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/upload-pages-
artifact@v3
with:
path: './dist'
- uses: actions/deploy-
pages@v4
v1.2.0)gh release create v1.2.0 \
--title "v1.2.0" \
--generate-notes \
./dist/app-linux \
./dist/app-macos \
./dist/app-windows.exe
GitHub Packages is a package registry integrated with GitHub. Host packages alongside your source code with unified permissions.
| Registry | Package type | URL |
|---|---|---|
| Container (GHCR) | Docker / OCI | ghcr.io/owner/image |
| npm | Node.js | npm.pkg.github.com |
| Maven | Java / Kotlin | maven.pkg.github.com |
| NuGet | .NET | nuget.pkg.github.com |
| RubyGems | Ruby | rubygems.pkg.github.com |
GITHUB_TOKEN provides automatic auth in Actions# In a GitHub Actions workflow
- name: Log in 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.sha }}
GitHub provides multiple layers of supply chain and code security — most are free for public repos and included in GitHub Advanced Security for private repos.
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
Static analysis engine. Finds SQL injection, XSS, command injection by analysing data flow. Enable via Actions workflow.
Automatically detects committed secrets — API keys, tokens, passwords. Over 200 partner patterns. Push protection can block the push before the secret reaches the remote.
GitHub Copilot is an AI pair programmer powered by large language models. It integrates into editors and the CLI.
| Product | Description |
|---|---|
| Individual | AI completions in VS Code, JetBrains, Neovim |
| Business | Org-managed, policy controls, audit logs |
| Enterprise | Fine-tuned on your codebase, knowledge bases |
| Chat | Conversational AI in the editor and on github.com |
| CLI | Explain and suggest terminal commands |
| In PRs | Auto-generated PR summaries and review comments |
gh copilot explain \
"awk '{print $2}' file.txt"
gh copilot suggest \
"find all .log files older \
than 30 days"
GitLab is an all-in-one DevSecOps platform. Where GitHub is a code host with bolted-on features, GitLab was designed as a single application covering the entire software development lifecycle.
| Edition | Hosting | Cost |
|---|---|---|
| Community Edition (CE) | Self-hosted only | Free, open-source (MIT) |
| Enterprise Edition (EE) | Self-hosted | Paid tiers (Premium, Ultimate) |
| GitLab.com | SaaS | Free tier + paid plans |
.gitlab-ci.yml, no marketplace| GitHub | GitLab |
|---|---|
| Repository | Project |
| Pull request | Merge request (MR) |
| GitHub Actions | GitLab CI/CD |
| Organisation | Group |
| GitHub Pages | GitLab Pages |
| CODEOWNERS | CODEOWNERS |
| Gist | Snippet |
# .gitlab-ci.yml
stages:
- build
- test
- deploy
build:
stage: build
image: node:22-alpine
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
test:
stage: test
image: node:22-alpine
script:
- npm ci
- npm test -- --coverage
deploy_production:
stage: deploy
environment:
name: production
script:
- ./deploy.sh production
when: manual
only:
- tags
| Aspect | GitLab CI | GitHub Actions |
|---|---|---|
| Config | Single .gitlab-ci.yml | Multiple workflow files |
| Reusability | include: templates | Marketplace, reusable workflows |
| Registry | Built-in, per project | GHCR (separate) |
| Environments | First-class, review apps | Protection rules |
| Auto DevOps | Zero-config pipeline | No equivalent |
| Feature | GitHub | GitLab |
|---|---|---|
| CI/CD | Actions (Marketplace) | Built-in (templates) |
| Container registry | GHCR | Built-in, per project |
| Static analysis | CodeQL (Advanced Security) | Built-in SAST, DAST, fuzzing |
| Secret scanning | Built-in + push protection | Built-in secret detection |
| Project management | Issues + Projects v2 | Issues + Boards + Epics |
| Self-hosted | Enterprise Server (paid) | CE (free) or EE (paid) |
| AI features | Copilot (paid) | Duo (paid) |
| Ecosystem | Huge — 20,000+ Actions | Smaller, template-based |
| Community | 100M+ developers | Smaller but significant |
Community fork of Gitea (post-governance dispute). Identical feature set, different governance. Backed by Codeberg (non-profit hosting).
| Platform | Best for | CI/CD | Self-host |
|---|---|---|---|
| GitHub | Open source, community | Actions | Enterprise (paid) |
| GitLab | Full DevOps lifecycle | Built-in | CE (free) |
| Bitbucket | Atlassian shops | Pipelines | Data Center (paid) |
| Gitea | Lightweight self-host | External | Yes (free) |
| Azure DevOps | Azure enterprises | Pipelines | Server (paid) |
ghgh CLI and authenticate.github/workflows/ci.yml for your next projectGitHub Docs — docs.github.com · GitHub CLI Manual — cli.github.com/manual · GitHub Skills — skills.github.com · GitLab Docs — docs.gitlab.com · Pro Git (2nd ed.) — git-scm.com/book (free)