github-cheat-sheet
Курируемый awesome-список · открыть репозиторий ↗
Источник: github-cheat-sheet — синхронизируется из внешнего репозитория как sparse-субмодуль (только список).
A collection of cool hidden and not so hidden features of Git and GitHub. This cheat sheet was inspired by Zach Holman’s Git and GitHub Secrets talk at Aloha Ruby Conference 2012 (slides) and his More Git and GitHub Secrets talk at WDCNZ 2013 (slides).
Shortlink: http://git.io/sheet
Read this in other languages: English, 한국어, 日本語, 简体中文, 正體中文.
GitHub Cheat Sheet is sponsored by Snapshot: create interactive professional-quality product photos using AI
Table of Contents#
- GitHub
- Ignore Whitespace
- Adjust Tab Space
- Commit History by Author
- Cloning a Repository
- Branch
- Gists
- Git.io
- Keyboard Shortcuts
- Line Highlighting in Repositories
- Closing Issues via Commit Messages
- Cross-Link Issues
- Locking Conversations
- CI Status on Pull Requests
- Filters
- Syntax Highlighting in Markdown Files
- Emojis
- Images/GIFs
- Quick Quoting
- Pasting Clipboard Image to Comments
- Quick Licensing
- Task Lists
- Relative Links
- Metadata and Plugin Support for GitHub Pages
- Viewing YAML Metadata in your Documents
- Rendering Tabular Data
- Rendering PDF
- Revert a Pull Request
- Diffs
- Hub
- Contribution Guidelines
- Octicons
- GitHub Student Developer Pack
- GitHub Resources
- SSH keys
- Profile Image
- Repository Templates
- Git
GitHub#
Ignore Whitespace#
Adding ?w=1 to any diff URL will remove any changes only in whitespace, enabling you to see only the code that has changed.
Read more about GitHub secrets.
Adjust Tab Space#
Adding ?ts=4 to a diff or file URL will display tab characters as 4 spaces wide instead of the default 8. The number after ts can be adjusted to suit your preference. This does not work on Gists, or raw file views, but a Chrome extension can automate this.
Here is a Go source file before adding ?ts=4:

…and this is after adding ?ts=4:

Commit History by Author#
To view all commits on a repo by author add ?author={user} to the URL.
https://github.com/rails/rails/commits/master?author=dhh
Read more about the differences between commits views.
Cloning a Repository#
When cloning a repository the .git can be left off the end.
$ git clone https://github.com/tiimgreen/github-cheat-sheetRead more about the Git clone command.
Branch#
Compare all Branches to Another Branch#
If you go to the repo’s Branches page, next to the Commits button:
https://github.com/{user}/{repo}/branches… you would see a list of all branches which are not merged into the main branch.
From here you can access the compare page or delete a branch with a click of a button.

Comparing Branches#
To use GitHub to compare branches, change the URL to look like this:
https://github.com/{user}/{repo}/compare/{range}where {range} = master...4-1-stable
For example:
https://github.com/rails/rails/compare/master...4-1-stable
{range} can be changed to things like:
https://github.com/rails/rails/compare/master@{1.day.ago}...master
https://github.com/rails/rails/compare/master@{2014-10-04}...masterHere, dates are in the format YYYY-MM-DD

Branches can also be compared in diff and patch views:
https://github.com/rails/rails/compare/master...4-1-stable.diff
https://github.com/rails/rails/compare/master...4-1-stable.patchRead more about comparing commits across time.
Compare Branches across Forked Repositories#
To use GitHub to compare branches across forked repositories, change the URL to look like this:
https://github.com/{user}/{repo}/compare/{foreign-user}:{branch}...{own-branch}For example:
https://github.com/rails/rails/compare/byroot:master...master
Gists#
Gists are an easy way to work with small bits of code without creating a fully fledged repository.

Add .pibb to the end of any Gist URL (like this) in order to get the HTML-only version suitable for embedding in any other site.
Gists can be treated as a repository so they can be cloned like any other:
$ git clone https://gist.github.com/tiimgreen/10545817
This means you also can modify and push updates to Gists:
$ git commit
$ git push
Username for 'https://gist.github.com':
Password for 'https://tiimgreen@gist.github.com':However, Gists do not support directories. All files need to be added to the repository root. Read more about creating Gists.
Git.io#
Git.io is a simple URL shortener for GitHub.

You can also use it via pure HTTP using Curl:
$ curl -i http://git.io -F "url=https://github.com/..."
HTTP/1.1 201 Created
Location: http://git.io/abc123
$ curl -i http://git.io/abc123
HTTP/1.1 302 Found
Location: https://github.com/...Keyboard Shortcuts#
When on a repository page, keyboard shortcuts allow you to navigate easily.
- Pressing
twill bring up a file explorer. - Pressing
wwill bring up the branch selector. - Pressing
swill focus the search field for the current repository. Pressing ↓ to select the “All GitHub” option changes the field to search all of GitHub. - Pressing
lwill edit labels on existing Issues. - Pressing
ywhen looking at a file (e.g.,https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md) will change your URL to one which, in effect, freezes the page you are looking at. If this code changes, you will still be able to see what you saw at that current time.
To see all of the shortcuts for the current page press ?:

Read more about search syntax you can use.
Line Highlighting in Repositories#
Either adding, e.g., #L52 to the end of a code file URL or simply clicking the line number will highlight that line number.
It also works with ranges, e.g., #L53-L60, to select ranges, hold shift and click two lines:
https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60
…превью ограничено; полный список — в репозитории.