Skip to content

Guide · Open source

How to use github-cheat-sheet: GitHub and Git tips guide

Updated · written with AI from the project's own documentation and checked against our catalogue data

github-cheat-sheet is a free, MIT-licensed reference page of lesser-known features of Git and GitHub, collected as short sections with example URLs, commands and screenshots. This guide explains how to read it, how to try its tips yourself, and which parts are most useful. After reading, you will know how to apply the URL tricks for diffs, commit history and branch comparisons, and where to find the rest.

GitHub Cheat Sheettiimgreen/github-cheat-sheet · ★ 60.1k · MIT

Quick start

  1. 1Open the sheet. Go to http://git.io/sheet or the repository README to read the tips.
  2. 2Pick one section. Choose a tip that solves a problem you have, such as noisy whitespace diffs.
  3. 3Edit the URL. Apply the pattern shown, for example adding ?w=1 to a diff URL on your own repository.
  4. 4Try a compare view. Replace the range in a compare URL with two branches you want to check.
  5. 5Clone if needed. Run git clone on the repository if you want a local copy of the README.

What github-cheat-sheet is and who it is for

It is a document, not a program. Its README collects tips on cool hidden and not so hidden features of Git and GitHub. The sheet was inspired by Zach Holman's Git and GitHub Secrets talks.

  • Developers who already use Git and GitHub daily and want to find lesser-known features
  • Students learning Git and GitHub who want practical examples
  • Team leads who want tips to share with their team

Is github-cheat-sheet right for you?

The sheet assumes some familiarity with the tools. It does not teach Git fundamentals step by step, and it is not a source of current GitHub documentation. The README links to older help articles, and the repository's last push was in April 2024.

  • Not for complete beginners who need Git basics from scratch
  • Not for people looking for software to install
  • Not for anyone needing current GitHub documentation

Clone the repository (optional)

You can read the sheet online at its homepage, http://git.io/sheet. If you want a local copy, you need Git installed. The README gives this clone command.

$ git clone https://github.com/tiimgreen/github-cheat-sheet

Use URL tricks to ignore whitespace and change tab width

Adding ?w=1 to any diff URL removes changes that are only whitespace, so you see only the code that has changed. Adding ?ts=4 to a diff or file URL displays tabs as 4 spaces wide instead of the default 8; you can change the number to suit your preference. The sheet notes that ?ts does not work on Gists or raw file views, and that a Chrome extension can automate the tab setting.

  • Append ?w=1 to a diff URL to hide whitespace-only changes
  • Append ?ts=4 to a diff or file URL to set tab width
  • Use a different number after ts to match your preference

View commit history by author and compare branches

To see all commits on a repository by one author, add ?author={user} to the commits URL. The sheet's example uses the rails/rails repository. To compare branches, change the URL to the compare form, where the range is written as base...head. The range can also use dates in YYYY-MM-DD format, and branches can be viewed as .diff or .patch.

  • Commits by author: add ?author={user} to the repo's commits URL
  • Compare: use /compare/{range} with a range such as master...4-1-stable
  • Diff and patch views: add .diff or .patch to a compare URL
https://github.com/rails/rails/commits/master?author=dhh https://github.com/rails/rails/compare/master...4-1-stable https://github.com/rails/rails/compare/master...4-1-stable.diff

Use Gists as small repositories

Gists are a way to work with small bits of code without creating a full repository. Add .pibb to the end of a Gist URL to get an HTML-only version for embedding in other sites. Gists can be cloned like any repository, and you can push updates to them. Gists do not support directories, so all files must sit in the repository root.

$ git clone https://gist.github.com/tiimgreen/10545817

What people use it for

  • Hide whitespace-only changes when reviewing a pull request diff
  • Check which branches have not been merged into the main branch
  • Look up one contributor's commits in a large project
  • Share a small code snippet as a Gist and embed it on another site
  • Teach a team a handful of Git and GitHub shortcuts in a session

Frequently asked questions

Is github-cheat-sheet free?

Yes. The project is licensed under the MIT licence, as stated in its repository information. The tips are read online at no cost.

What do I need to use github-cheat-sheet?

You can read it in a browser. Git is only needed if you want to run the clone example from the README. Some tips assume you already have a GitHub account and a repository to test on.

How do I install github-cheat-sheet?

There is nothing to install. Read it online at http://git.io/sheet, or clone the repository with git clone https://github.com/tiimgreen/github-cheat-sheet if you want a local copy.

Is github-cheat-sheet still up to date?

Not fully. The README links to older GitHub help articles, and the last push was in April 2024. Check current GitHub documentation for anything that must be accurate today.

What are good alternatives to github-cheat-sheet?

Comparable projects include Oh My Git, Learn Git Branching and Pro Git. Learn Git Branching and Pro Git suit readers who want more foundational learning, while github-cheat-sheet focuses on GitHub tips and hidden features.

Can I use github-cheat-sheet to learn Git from scratch?

It is not designed for that. The sheet assumes some familiarity with Git and GitHub, so beginners may want a fundamentals resource first and then use this as a follow-up.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use github-cheat-sheet if you already use Git and GitHub and want a quick list of features you may have missed, or a set of examples to share with a team. Pick Pro Git or Learn Git Branching if you need to learn the basics, and check current GitHub documentation for anything that changes often.

Install options & downloads