# GitHub Cheat Sheet — Content Guide

> A community-maintained reference of "cool hidden and not so hidden features of Git and GitHub" — short tips, URL hacks, keyboard shortcuts, and `git` recipes — collected by Tim Green and contributors. The whole project is one Markdown file (`README.md`) with four community translations alongside it. There is nothing to install and no code to run; the deliverable is the prose itself.

This guide tells you what's inside the collection, the cleanest way to read it, what each section covers, and how to contribute. It mirrors the repository at commit `746af1b` (2023-10-15) and quotes real anchors and file paths so you can jump from this guide straight into the source.

> [!NOTE]
> The repository is shipped under the **MIT License** (`LICENSE`, © 2014 Tim Green). You can copy, adapt, or redistribute the cheat sheet provided you keep the copyright and license notice.

---

## What's in This Collection

The repository's working tree is small and flat — eight files at the root, no subdirectories of content:

| Path | What's there |
|------|--------------|
| `README.md` | The English cheat sheet itself (~43 KB). This is the primary artifact. |
| `README.ja.md` | Japanese translation of the cheat sheet. |
| `README.ko.md` | Korean translation (한국어). |
| `README.zh-cn.md` | Simplified Chinese translation (简体中文). |
| `README.zh-tw.md` | Traditional Chinese translation (正體中文). |
| `CONTRIBUTING.md` | Style rules contributors must follow when adding a section. |
| `LICENSE` | MIT license, © 2014 Tim Green. |
| `.travis.yml` | CI configuration that link-checks every README on push. |

The English `README.md` is divided into two top-level sections, with deeply nested subsections under each:

| Section | What's covered | Source anchor |
|---------|----------------|---------------|
| **GitHub** | Browser-side features: URL tricks, keyboard shortcuts, issue and PR conveniences, Markdown rendering, contribution metadata files, octicons, the Student Developer Pack, repository templates. | [`#github`](https://github.com/tiimgreen/github-cheat-sheet#github) |
| **Git** | Command-line features: branch shortcuts, commit hygiene, custom log/status formatting, search (`git grep`, `git show :/query`), aliases, auto-correct, color, and curated reading lists. | [`#git`](https://github.com/tiimgreen/github-cheat-sheet#git) |

> [!TIP]
> The README's own [Table of Contents](https://github.com/tiimgreen/github-cheat-sheet#table-of-contents) lists every subsection with anchor links — use it as the index when you want to jump to a specific tip rather than reading top-to-bottom.

The collection is a living snapshot: contributors have added tips and translations over time, but the core structure and most entries have been stable since the initial release.

> [!IMPORTANT]
> Last activity on the repository is the commit captured by this guide: `746af1b` on 2023-10-15. Treat the tips as a snapshot of the GitHub UI and Git CLI as of that date. A handful of UI features (e.g. specific button labels, screenshot images hosted on third-party CDNs) may have shifted since.

---

## How to Read / Use This

The cheat sheet is **a reference, not a tutorial.** It assumes you already use Git and GitHub day-to-day; each entry is a single self-contained tip with a code example and a link out to the canonical Git or GitHub documentation. There is no required reading order.

**Suggested entry points:**

=== "Browse by topic"

    Open [`README.md`](https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md), scroll the [Table of Contents](https://github.com/tiimgreen/github-cheat-sheet#table-of-contents), and click into whatever subsection looks useful. Most entries are 5-15 lines plus a screenshot.

=== "Search by keyword"

    Press `t` on the GitHub repo page (file finder) or use your browser's in-page search inside `README.md`. Section titles use exact feature names (e.g. "Stripspace", "Empty Commits", "Styled Git Log"), so a keyword search lands you directly on the relevant tip.

=== "Read in another language"

    Pick the README that matches your locale: `README.ja.md` (日本語), `README.ko.md` (한국어), `README.zh-cn.md` (简体中文), `README.zh-tw.md` (正體中文). All four are linked from the top of `README.md`. The translations may lag the English version on the most recently added subsections; the English file is the canonical source.

**Prerequisites:** the GitHub-side tips assume a GitHub.com account and basic familiarity with the web UI (issues, pull requests, repo settings). The Git-side tips assume a working `git` install on your shell. No Git or GitHub Enterprise version is pinned in the README — tips that depend on a specific feature usually link to the announcement post.

> [!NOTE]
> The repository's only operational machinery is `.travis.yml`. On every push, Travis CI installs the [`awesome_bot`](https://github.com/dkhamsing/awesome_bot) gem and runs it against `README.md` and each translation to flag broken links. That's why most outgoing links in the cheat sheet still resolve — they're checked on every contribution.

---

## Section Walkthroughs

The README is organized as a Table of Contents followed by two long ` ## ` sections. The walkthroughs below mirror that structure and call out the most useful subsections inside each.

### Section 1 — GitHub

The "GitHub" section collects browser-side tricks: URL parameters that change how diffs and blobs render, keyboard shortcuts inside the GitHub UI, conveniences for issues and pull requests, Markdown rendering features, and metadata files that change how a repository behaves on GitHub. Each subsection is a short standalone tip; you can read them in any order.

The subsections fall into roughly five groups:

**URL hacks.** Append-this-to-a-URL tricks that unlock hidden views without leaving the page. Examples: `?w=1` strips whitespace from a diff ([Ignore Whitespace](https://github.com/tiimgreen/github-cheat-sheet#ignore-whitespace)), `?ts=4` reflows tab indentation in blobs ([Adjust Tab Space](https://github.com/tiimgreen/github-cheat-sheet#adjust-tab-space)), `?author={user}` filters commit history ([Commit History by Author](https://github.com/tiimgreen/github-cheat-sheet#commit-history-by-author)), `#L52` and `#L53-L60` highlight individual lines or ranges in a file view ([Line Highlighting in Repositories](https://github.com/tiimgreen/github-cheat-sheet#line-highlighting-in-repositories)), and `.diff` / `.patch` extensions on a pull-request URL return the raw patch ([Diff or Patch of Pull Request](https://github.com/tiimgreen/github-cheat-sheet#diff-or-patch-of-pull-request)). The [Branch](https://github.com/tiimgreen/github-cheat-sheet#branch) cluster — Compare all Branches, Comparing Branches, Compare Branches across Forked Repositories — is a deeper dive into the `/compare/{range}` URL form, including time-anchored ranges like `master@{1.day.ago}...master`.

**Keyboard shortcuts.** [Keyboard Shortcuts](https://github.com/tiimgreen/github-cheat-sheet#keyboard-shortcuts) covers the big ones (`t` for the file explorer, `w` for the branch selector, `s` to focus search, `l` to edit issue labels, `y` to canonicalize a blob URL to its commit-pinned form). Press `?` on any GitHub page for the full list. [Quick Quoting](https://github.com/tiimgreen/github-cheat-sheet#quick-quoting) (highlight + `r`) inserts a block quote into the comment box.

**Issues and pull requests.** [Closing Issues via Commit Messages](https://github.com/tiimgreen/github-cheat-sheet#closing-issues-via-commit-messages) lists the keywords (`fix/fixes/fixed`, `close/closes/closed`, `resolve/resolves/resolved`) that auto-close an issue when the commit lands on the default branch. [Cross-Link Issues](https://github.com/tiimgreen/github-cheat-sheet#cross-link-issues) shows the `{user}/{repo}#NUMBER` shorthand. [Locking Conversations](https://github.com/tiimgreen/github-cheat-sheet#locking-conversations) and [CI Status on Pull Requests](https://github.com/tiimgreen/github-cheat-sheet#ci-status-on-pull-requests) round out the workflow tips. [Filters](https://github.com/tiimgreen/github-cheat-sheet#filters) is the densest entry: it walks through the issue/PR search syntax — `is:issue label:activerecord`, `is:issue -label:activerecord`, `is:pr`, `is:merged`, `status:success`. [Revert a Pull Request](https://github.com/tiimgreen/github-cheat-sheet#revert-a-pull-request) covers the one-click revert button after merge.

**Markdown and content rendering.** [Syntax Highlighting in Markdown Files](https://github.com/tiimgreen/github-cheat-sheet#syntax-highlighting-in-markdown-files) explains how language tags after a fenced code block trigger Linguist-driven highlighting and points to the [languages YAML file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) for the list of valid tags. [Emojis](https://github.com/tiimgreen/github-cheat-sheet#emojis) covers the `:name:` syntax and lists the top-five most-used emojis on GitHub. [Images/GIFs](https://github.com/tiimgreen/github-cheat-sheet#imagesgifs) and its sub-entry [Embedding Images in GitHub Wiki](https://github.com/tiimgreen/github-cheat-sheet#embedding-images-in-github-wiki) cover image syntax including the wiki-only `[[ url | height = ... ]]` form. [Pasting Clipboard Image to Comments](https://github.com/tiimgreen/github-cheat-sheet#pasting-clipboard-image-to-comments) (Chrome only) explains the screenshot-to-comment paste flow. [Task Lists](https://github.com/tiimgreen/github-cheat-sheet#task-lists), [Relative Links](https://github.com/tiimgreen/github-cheat-sheet#relative-links), [Metadata and Plugin Support for GitHub Pages](https://github.com/tiimgreen/github-cheat-sheet#metadata-and-plugin-support-for-github-pages), [Viewing YAML Metadata in your Documents](https://github.com/tiimgreen/github-cheat-sheet#viewing-yaml-metadata-in-your-documents), [Rendering Tabular Data](https://github.com/tiimgreen/github-cheat-sheet#rendering-tabular-data), and [Rendering PDF](https://github.com/tiimgreen/github-cheat-sheet#rendering-pdf) round out the Markdown story. The [Diffs](https://github.com/tiimgreen/github-cheat-sheet#diffs) cluster — Rendered Prose Diffs, Diffable Maps, Expanding Context in Diffs, Rendering and diffing images — covers GitHub's content-aware diff renderers.

**Repository metadata, profile, and resources.** [Quick Licensing](https://github.com/tiimgreen/github-cheat-sheet#quick-licensing) describes the in-browser `LICENSE` and `.gitignore` template picker. The [Contribution Guidelines](https://github.com/tiimgreen/github-cheat-sheet#contribution-guidelines) cluster documents three special files GitHub recognizes — `CONTRIBUTING`, `ISSUE_TEMPLATE`, `PULL_REQUEST_TEMPLATE` — and where they can live (`/` or `.github/`). [Hub](https://github.com/tiimgreen/github-cheat-sheet#hub) is a brief pointer to the [`hub`](https://github.com/github/hub) CLI wrapper. [Octicons](https://github.com/tiimgreen/github-cheat-sheet#octicons), [GitHub Student Developer Pack](https://github.com/tiimgreen/github-cheat-sheet#github-student-developer-pack), [SSH keys](https://github.com/tiimgreen/github-cheat-sheet#ssh-keys) (`https://github.com/{user}.keys`), [Profile Image](https://github.com/tiimgreen/github-cheat-sheet#profile-image) (`https://github.com/{user}.png`), and [Repository Templates](https://github.com/tiimgreen/github-cheat-sheet#repository-templates) cover account- and repo-level settings. [GitHub Resources](https://github.com/tiimgreen/github-cheat-sheet#github-resources) and its sub-table [GitHub Talks](https://github.com/tiimgreen/github-cheat-sheet#github-talks) are curated link tables — useful as a starting list, but they will age fastest of any section.

> [!TIP]
> Several "URL hack" tips combine well. For example, link to a specific commit-pinned line range in a file (`y` to canonicalize the blob URL, then append `#L53-L60`), or share a whitespace-suppressed diff for a forked branch comparison (`/compare/byroot:master...master?w=1`).

### Section 2 — Git

The "Git" section is for the command line. Tips here usually take the form *one-liner you didn't know about*, and most entries link out to the official [git-scm.com](http://git-scm.com/) reference for the underlying command. The subsections fall into three groups:

**Branching, committing, and history.** [Remove All Deleted Files from the Working Tree](https://github.com/tiimgreen/github-cheat-sheet#remove-all-deleted-files-from-the-working-tree) (`git rm $(git ls-files -d)`), [Previous Branch](https://github.com/tiimgreen/github-cheat-sheet#previous-branch) (`git checkout -`), [Stripspace](https://github.com/tiimgreen/github-cheat-sheet#stripspace) (whitespace cleanup via `git stripspace`), [Checking out Pull Requests](https://github.com/tiimgreen/github-cheat-sheet#checking-out-pull-requests) (the `+refs/pull/*/head:refs/remotes/origin/pr/*` refspec, both per-repo and globally), [Empty Commits](https://github.com/tiimgreen/github-cheat-sheet#empty-commits) (`git commit --allow-empty` and four real-world use cases), [Merged Branches](https://github.com/tiimgreen/github-cheat-sheet#merged-branches) (`git branch --merged` / `--no-merged`), and [Fixup and Autosquash](https://github.com/tiimgreen/github-cheat-sheet#fixup-and-autosquash) (`git commit --fixup=abcde` then `git rebase abcde^ --autosquash -i`).

**Custom output and search.** [Styled Git Status](https://github.com/tiimgreen/github-cheat-sheet#styled-git-status) (`git status -sb`), [Styled Git Log](https://github.com/tiimgreen/github-cheat-sheet#styled-git-log) (a long `--pretty=format` invocation that produces a colored, graph-decorated log — credited to Palesz on Stack Overflow), [Git Query](https://github.com/tiimgreen/github-cheat-sheet#git-query) (`git show :/query` to find the most recent commit message containing a string), and [Git Grep](https://github.com/tiimgreen/github-cheat-sheet#git-grep) (multi-pattern matching with `-e`, `--and`, `--or`, `--not`).

**Configuration: aliases, auto-correct, color.** [Web Server for Browsing Local Repositories](https://github.com/tiimgreen/github-cheat-sheet#web-server-for-browsing-local-repositories) (`git instaweb`) is a one-liner. The bigger entry is [Git Configurations](https://github.com/tiimgreen/github-cheat-sheet#git-configurations), which contains three subsections: [Aliases](https://github.com/tiimgreen/github-cheat-sheet#aliases) (a curated table of aliases like `git cm` / `git co` / `git ac` / `git st` / `git tags` / `git branches` / `git cleanup` / `git remotes` / `git lg`, each with the exact `git config --global alias.X 'Y'` command to install it), [Auto-Correct](https://github.com/tiimgreen/github-cheat-sheet#auto-correct) (`git config --global help.autocorrect 15` for a 1.5-second corrected-command delay), and [Color](https://github.com/tiimgreen/github-cheat-sheet#color) (`git config --global color.ui 1`).

**Reading lists.** [Git Resources](https://github.com/tiimgreen/github-cheat-sheet#git-resources), [Git Books](https://github.com/tiimgreen/github-cheat-sheet#git-books), [Git Videos](https://github.com/tiimgreen/github-cheat-sheet#git-videos), and [Git Articles](https://github.com/tiimgreen/github-cheat-sheet#git-articles) close out the file with curated link tables to official documentation, books, and conference talks.

> [!CAUTION]
> Two entries quote shell pipelines verbatim — copy them carefully. The `git cleanup` alias (`git branch --merged | grep -v '*' | xargs git branch -d`) deletes any local branch that has been merged into the current one. Run `git branch --merged` first, alone, to confirm the list before installing the alias. Likewise, `git rm $(git ls-files -d)` from the [Remove All Deleted Files from the Working Tree](https://github.com/tiimgreen/github-cheat-sheet#remove-all-deleted-files-from-the-working-tree) tip stages every deletion git knows about — fine in a clean working tree, surprising if you have multiple in-progress deletions you wanted to keep separate.

> [!NOTE]
> A few links in the Git section point to articles or hosts that have shifted since 2023 (e.g. `confreaks.tv`, `i.imgur.com`, third-party blog posts). The repository's CI runs `awesome_bot --allow-redirect`, so a 301 still passes link-check; if a link 404s for you, treat it as link-rot from the upstream host, not a content error in the cheat sheet.

---

## Contributing / Extending

Contributions follow the rules in [`CONTRIBUTING.md`](https://github.com/tiimgreen/github-cheat-sheet/blob/master/CONTRIBUTING.md). The flow is the standard fork-and-PR five-step:

- [ ] Fork the repository.
- [ ] Add your section, following the styling rules below.
- [ ] Commit your changes.
- [ ] Push the commit to your fork.
- [ ] Open a Pull Request against `tiimgreen/github-cheat-sheet`.

**Styling rules** (verbatim from `CONTRIBUTING.md`):

- Use `###` headers for new sections.
- Also use `###` for **categories** (groups of related sections) and `####` for **subcategories** within a category.
- Add a link to your new section/category in the [Table of Contents](https://github.com/tiimgreen/github-cheat-sheet#table-of-contents). Use **relative** links (e.g. `#new-section`).
- Include examples wherever possible — preferably GIFs.
- Wrap command-line examples in a ` ```bash ` code block.
- End every section with a `Read more about ...` link to the relevant page on [git-scm.com/docs](http://git-scm.com/docs), [help.github.com](https://help.github.com), or whichever source is canonical.
- If your contribution is a **translation**, link your translation file relative to the README, immediately above the [Table of Contents](https://github.com/tiimgreen/github-cheat-sheet#table-of-contents).

> [!IMPORTANT]
> Travis CI runs `awesome_bot` against `README.md` and each translation on every push (see `.travis.yml`). The check passes redirects (`--allow-redirect`) and duplicates (`--allow-dupe`), and a global `wl=` whitelist excludes a small set of legitimate-but-flagged URLs. Your PR must pass this check; if it fails, the CI log will name the broken link.

---

## Related Resources

The README aggregates several curated link lists. The two largest are reproduced below for quick reference; both are also browsable in `README.md`.

**GitHub-related** (from [GitHub Resources](https://github.com/tiimgreen/github-cheat-sheet#github-resources)):

| Title | Link |
|-------|------|
| GitHub Explore | <https://github.com/explore> |
| GitHub Blog | <https://github.com/blog> |
| GitHub Help | <https://help.github.com/> |
| GitHub Training | <https://training.github.com/> |
| GitHub Developer | <https://developer.github.com/> |
| GitHub Education | <https://education.github.com/> |
| GitHub Best Practices | <https://www.datree.io/resources/github-best-practices> |

**Git-related** (selected highlights from [Git Resources](https://github.com/tiimgreen/github-cheat-sheet#git-resources)):

| Title | Link |
|-------|------|
| Official Git Site | <http://git-scm.com/> |
| Pro Git (book, free online) | <http://git-scm.com/book> |
| Code School Try Git | <http://try.github.com/> |
| Git Immersion | <http://gitimmersion.com/> |
| Learn Git Branching (visual) | <http://pcottle.github.io/learnGitBranching/> |
| Collection of `.gitignore` templates | <https://github.com/github/gitignore> |
| `git-extra-commands` (Unixorn) | <https://github.com/unixorn/git-extra-commands> |

**Original inspirations** named in the README intro:

- Zach Holman, *Git and GitHub Secrets*, Aloha Ruby Conference 2012 — [video on Confreaks](http://confreaks.tv/videos/aloharuby2012-git-and-github-secrets), [slides](https://speakerdeck.com/holman/git-and-github-secrets).
- Zach Holman, *More Git and GitHub Secrets*, WDCNZ 2013 — [video on Vimeo](https://vimeo.com/72955426), [slides](https://speakerdeck.com/holman/more-git-and-github-secrets).

> [!WARNING]
> The `git.io` URL shortener documented in the cheat sheet's [Git.io](https://github.com/tiimgreen/github-cheat-sheet#gitio) section — including the `http://git.io/sheet` shortlink for this repository — was **retired by GitHub in April 2022** and no longer resolves. Share the cheat sheet using the full URL `https://github.com/tiimgreen/github-cheat-sheet` instead.

---

_Generated May 2026 from tiimgreen/github-cheat-sheet at 746af1b. AI-generated documentation. The library is checked by sampling (three repositories so far); this guide was not individually reviewed. Verify against the project before relying on it. Unofficial; not affiliated with or reviewed by the project._
