GitHubPrintable

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.

Back to the GitHub tutorial

Account & sign-in

Command / placeWhat it doesLesson
gh auth loginSign in from the terminalIntroduction
gh auth statusCheck you're signed inIntroduction
Settings, Password and authenticationTurn on two-factor authIntroduction
Repo named usernameProfile READMEIntroduction

Repositories

Command / placeWhat it doesLesson
+ menu, New repositoryCreate a repoRepositories
gh repo create name --publicCreate from the terminalRepositories
README.mdProject front page (Markdown)Repositories
Press . on a repo pageOpen the browser editorRepositories

Markdown

SyntaxWhat it doesLesson
# Title / ## SectionHeadingsMarkdown
**bold** / *italic*EmphasisMarkdown
[text](url)LinkMarkdown
![alt text](image.png)ImageMarkdown
Three backticks and a languageHighlighted code blockMarkdown
Pipes between columns, dashes under the headerTableMarkdown

SSH & tokens

Command / placeWhat it doesLesson
ssh-keygen -t ed25519 -C "you@x.com"Create an SSH keySSH & Authentication
Settings, SSH and GPG keysAdd your .pub keySSH & Authentication
ssh -T git@github.comTest the connectionSSH & Authentication
git remote set-url origin git@github.com:user/repo.gitSwitch to SSHSSH & Authentication
Developer settings, Personal access tokensToken for HTTPSSSH & Authentication

Push, pull & clone

CommandWhat it doesLesson
git remote add origin <url>Connect to GitHubPush & pull
git remote -vList remotesPush & pull
git push -u origin mainFirst push of a branchPush & pull
git push / git pullSend / receive commitsPush & pull
git fetchDownload without mergingPush & pull
git clone <url>Copy a repo to your computerPush & pull

Pull requests

CommandWhat it doesLesson
git switch -c featureStart a branchPull requests
git push -u origin featurePublish the branchPull requests
gh pr create --fillOpen a pull requestPull requests
gh pr merge --squashMerge as one commitPull requests

Code review

Command / placeWhat it doesLesson
Files changed, + on a lineComment on codeCode Review
Suggestion buttonPropose an exact fixCode Review
gh pr checkout 42Test a PR locallyCode Review
gh pr review 42 --approveApprove from the terminalCode Review
.github/CODEOWNERSRequest reviewers automaticallyCode Review

Forks

CommandWhat it doesLesson
Fork buttonYour copy of someone's repoForks
git remote add upstream <url>Track the original projectForks
git fetch upstreamGet the project's new commitsForks
git merge upstream/mainUpdate your mainForks
Sync fork buttonUpdate your fork on GitHubForks

Issues

SyntaxWhat it doesLesson
Fixes #12Close issue 12 on mergeIssues
@usernameMention someoneIssues
- [ ] taskCheckbox task listIssues
is:open label:bugFilter issuesIssues
gh issue listList issues in the terminalIssues

Projects & Discussions

Place / syntaxWhat it doesLesson
Profile, Projects, New projectCreate a planning boardProjects
Board / Table / RoadmapDifferent views of the same workProjects
Project menu, WorkflowsMove items automaticallyProjects
.github/ISSUE_TEMPLATE/*.ymlIssue formsProjects
Settings, Features, DiscussionsTurn on a Q&A forumProjects

GitHub Pages

StepWhat it doesLesson
index.html in the rootThe home pagePages
Settings, Pages, main / rootTurn publishing onPages
username.github.io/repoYour site's addressPages
git pushRepublish after changesPages

Actions

SyntaxWhat it doesLesson
.github/workflows/ci.ymlWhere workflows liveActions
on: [push, pull_request]When the workflow runsActions
runs-on: ubuntu-latestChoose the runnerActions
uses: actions/checkout@v4Download the repositoryActions
run: npm testRun a commandActions
${{ secrets.NAME }}Use a stored secretActions

Releases

CommandWhat it doesLesson
MAJOR.MINOR.PATCHBreaking, feature, fixReleases
git tag -a v1.2.0 -m "..."Tag the versionReleases
gh release create v1.2.0 --generate-notesPublish a releaseReleases
gh release create v2.0.0-beta.1 --prereleasePublish a test versionReleases

Security

Place / fileWhat it doesLesson
Settings, Rules / BranchesProtect mainSecurity
Settings, CollaboratorsManage who has accessSecurity
.github/dependabot.ymlAutomatic dependency updatesSecurity
Settings, Code securitySecret scanning and push protectionSecurity
SECURITY.mdHow to report vulnerabilitiesSecurity

GitHub CLI

CommandWhat it doesLesson
gh repo create name --source=. --pushPublish a local projectGitHub CLI
gh pr statusYour PRs and review requestsGitHub CLI
gh pr checks --watchWait for testsGitHub CLI
gh run watchFollow a workflow runGitHub CLI
gh browseOpen the repo in the browserGitHub CLI
gh api <endpoint>Call the GitHub APIGitHub CLI

Profile, templates, gists & wikis

Command / placeWhat it doesLesson
Repository named <username> with README.mdProfile READMEProfile & Portfolio
Profile, Customize your pinsShow up to 6 repositoriesProfile & Portfolio
.github/ISSUE_TEMPLATE/bug_report.mdIssue templateTemplates & Community Files
.github/pull_request_template.mdPull request templateTemplates & Community Files
Settings, Template repositoryStart projects with Use this templateTemplates & Community Files
gh gist create file --publicShare a snippetGists & Wikis
git clone <repo>.wiki.gitEdit a wiki locallyGists & Wikis

Organizations & Codespaces

Command / placeWhat it doesLesson
People, Invite memberAdd someone to an organizationOrganizations & Teams
Teams, New team; repository role Read to AdminGrant access by teamOrganizations & Teams
@org/teamMention or request review from a teamOrganizations & Teams
Settings, Rules, RulesetsProtect branches across repositoriesOrganizations & Teams
Code, Codespaces, Create codespaceCloud dev environmentCodespaces
.devcontainer/devcontainer.jsonDefine tools and extensionsCodespaces
gh codespace stop / deleteSave compute timeCodespaces
Press . on a repositoryOpen github.devCodespaces

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.

The GitHub lessons behind this cheat sheet