GitHub Cheat Sheet
Sign-in, repositories, Markdown, pull requests, reviews, forks, projects, Pages, Actions, releases, security and the gh command, all on one printable page.
Account & sign-in
| Command / place | What it does | Lesson |
|---|---|---|
gh auth login | Sign in from the terminal | Introduction |
gh auth status | Check you're signed in | Introduction |
| Settings, Password and authentication | Turn on two-factor auth | Introduction |
Repo named username | Profile README | Introduction |
Repositories
| Command / place | What it does | Lesson |
|---|---|---|
| + menu, New repository | Create a repo | Repositories |
gh repo create name --public | Create from the terminal | Repositories |
README.md | Project front page (Markdown) | Repositories |
Press . on a repo page | Open the browser editor | Repositories |
Markdown
SSH & tokens
| Command / place | What it does | Lesson |
|---|---|---|
ssh-keygen -t ed25519 -C "you@x.com" | Create an SSH key | SSH & Authentication |
| Settings, SSH and GPG keys | Add your .pub key | SSH & Authentication |
ssh -T git@github.com | Test the connection | SSH & Authentication |
git remote set-url origin git@github.com:user/repo.git | Switch to SSH | SSH & Authentication |
| Developer settings, Personal access tokens | Token for HTTPS | SSH & Authentication |
Push, pull & clone
| Command | What it does | Lesson |
|---|---|---|
git remote add origin <url> | Connect to GitHub | Push & pull |
git remote -v | List remotes | Push & pull |
git push -u origin main | First push of a branch | Push & pull |
git push / git pull | Send / receive commits | Push & pull |
git fetch | Download without merging | Push & pull |
git clone <url> | Copy a repo to your computer | Push & pull |
Pull requests
| Command | What it does | Lesson |
|---|---|---|
git switch -c feature | Start a branch | Pull requests |
git push -u origin feature | Publish the branch | Pull requests |
gh pr create --fill | Open a pull request | Pull requests |
gh pr merge --squash | Merge as one commit | Pull requests |
Code review
| Command / place | What it does | Lesson |
|---|---|---|
| Files changed, + on a line | Comment on code | Code Review |
| Suggestion button | Propose an exact fix | Code Review |
gh pr checkout 42 | Test a PR locally | Code Review |
gh pr review 42 --approve | Approve from the terminal | Code Review |
.github/CODEOWNERS | Request reviewers automatically | Code Review |
Forks
Issues
Projects & Discussions
| Place / syntax | What it does | Lesson |
|---|---|---|
| Profile, Projects, New project | Create a planning board | Projects |
| Board / Table / Roadmap | Different views of the same work | Projects |
| Project menu, Workflows | Move items automatically | Projects |
.github/ISSUE_TEMPLATE/*.yml | Issue forms | Projects |
| Settings, Features, Discussions | Turn on a Q&A forum | Projects |
GitHub Pages
Actions
| Syntax | What it does | Lesson |
|---|---|---|
.github/workflows/ci.yml | Where workflows live | Actions |
on: [push, pull_request] | When the workflow runs | Actions |
runs-on: ubuntu-latest | Choose the runner | Actions |
uses: actions/checkout@v4 | Download the repository | Actions |
run: npm test | Run a command | Actions |
${{ secrets.NAME }} | Use a stored secret | Actions |
Releases
Security
| Place / file | What it does | Lesson |
|---|---|---|
| Settings, Rules / Branches | Protect main | Security |
| Settings, Collaborators | Manage who has access | Security |
.github/dependabot.yml | Automatic dependency updates | Security |
| Settings, Code security | Secret scanning and push protection | Security |
SECURITY.md | How to report vulnerabilities | Security |
GitHub CLI
| Command | What it does | Lesson |
|---|---|---|
gh repo create name --source=. --push | Publish a local project | GitHub CLI |
gh pr status | Your PRs and review requests | GitHub CLI |
gh pr checks --watch | Wait for tests | GitHub CLI |
gh run watch | Follow a workflow run | GitHub CLI |
gh browse | Open the repo in the browser | GitHub CLI |
gh api <endpoint> | Call the GitHub API | GitHub CLI |
Profile, templates, gists & wikis
| Command / place | What it does | Lesson |
|---|---|---|
Repository named <username> with README.md | Profile README | Profile & Portfolio |
| Profile, Customize your pins | Show up to 6 repositories | Profile & Portfolio |
.github/ISSUE_TEMPLATE/bug_report.md | Issue template | Templates & Community Files |
.github/pull_request_template.md | Pull request template | Templates & Community Files |
| Settings, Template repository | Start projects with Use this template | Templates & Community Files |
gh gist create file --public | Share a snippet | Gists & Wikis |
git clone <repo>.wiki.git | Edit a wiki locally | Gists & Wikis |
Organizations & Codespaces
| Command / place | What it does | Lesson |
|---|---|---|
| People, Invite member | Add someone to an organization | Organizations & Teams |
| Teams, New team; repository role Read to Admin | Grant access by team | Organizations & Teams |
@org/team | Mention or request review from a team | Organizations & Teams |
| Settings, Rules, Rulesets | Protect branches across repositories | Organizations & Teams |
| Code, Codespaces, Create codespace | Cloud dev environment | Codespaces |
.devcontainer/devcontainer.json | Define tools and extensions | Codespaces |
gh codespace stop / delete | Save compute time | Codespaces |
Press . on a repository | Open github.dev | Codespaces |
How to use this GitHub cheat sheet
This GitHub cheat sheet gathers the commands, settings and syntax from the whole course on one page, in the same order as the lessons: signing in, repositories, Markdown, your profile, SSH keys, pushing and pulling, pull requests, code review, forks, issues, templates, Projects, gists and wikis, GitHub Pages, Actions, releases, organizations, security, Codespaces and the GitHub CLI. Each row links to the lesson that explains it with examples and common mistakes.
Some rows are commands you type, and others are places in GitHub's interface, such as "Settings, Pages", because much of GitHub is configured on the website. Keep the page open while you work, type part of a command or setting into the filter box to find it quickly, or print it and keep it beside your keyboard while you practise.