1
0
mirror of https://github.com/tiimgreen/github-cheat-sheet.git synced 2025-08-09 01:16:37 +02:00

Merge branch 'master' into korean

This commit is contained in:
Shim Tw
2014-04-17 08:17:03 +09:00

145
README.md
View File

@@ -14,6 +14,7 @@ A collection of cool hidden and not so hidden features of Git and GitHub. This c
- [Line Highlighting in Repositories](#line-highlighting-in-repositories)
- [Closing Issues via Commit Messages](#closing-issues-via-commit-messages)
- [Cross-Link Issues](#cross-link-issues)
- [CI Status on Pull Requests](#ci-status-on-pull-requests)
- [Syntax Highlighting in Markdown Files](#syntax-highlighting-in-markdown-files)
- [Emojis](#emojis)
- [Images/GIFs](#imagesgifs)
@@ -27,11 +28,15 @@ A collection of cool hidden and not so hidden features of Git and GitHub. This c
- [Rendered prose Diffs](#rendered-prose-diffs)
- [Diffable Maps](#diffable-maps)
- [Expanding Context in Diffs](#expanding-context-in-diffs)
- [Diff or Patch of Pull Request](#diff-or-patch-of-pull-request)
- [Hub](#hub)
- [Decreasing Contributor Friction](#decreasing-contributor-friction)
- [Contributing Guidelines](#contributing-guidelines)
- [GitHub Resources](#github-resources)
- [GitHub Talks](#github-talks)
- [Git](#git)
- [Previous Branch](#previous-branch)
- [Stripspace](#stripspace)
- [Checking out Pull Requests](#checking-out-pull-requests)
- [Empty Commits :trollface:](#empty-commits-trollface)
- [Styled Git Status](#styled-git-status)
@@ -43,11 +48,15 @@ A collection of cool hidden and not so hidden features of Git and GitHub. This c
- [Aliases](#aliases)
- [Auto-Correct](#auto-correct)
- [Color](#color)
- [Git Resources](#git-resources)
- [Git Books](#git-books)
## GitHub
### Ignore Whitespace
Adding `?w=1` to any diff URL will remove any changes only in whitespace, enabling you to see only that code that has changed.
![Diff without whitespace](https://camo.githubusercontent.com/797184940defadec00393e6559b835358a863eeb/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f776869746573706163652e706e67)
[*Read more about GitHub secrets.*](https://github.com/blog/967-github-secrets)
### Commit History by Author
@@ -57,6 +66,8 @@ To view all commits on a repo by author add `?author=username` to the URL.
https://github.com/rails/rails/commits/master?author=dhh
```
![DHH commit history](http://i.imgur.com/mDWwuaY.png)
[*Read more about the differences between commits views.*](https://help.github.com/articles/differences-between-commit-views)
### Cloning a Repository
@@ -78,10 +89,13 @@ 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
```
![Rails branch compare example](http://i.imgur.com/0Z52X5Y.png)
`{range}` can be changed to things like:
```
@@ -89,6 +103,10 @@ https://github.com/rails/rails/compare/master@{1.day.ago}...master
https://github.com/rails/rails/compare/master@{2014-10-04}...master
```
*Dates are in the format `YYYY-DD-MM`*
![Another compare example](http://i.imgur.com/5dtzESz.png)
...which allows you to see the difference on the master branch up a set time ago or a specified date.
[*Read more about comparing commits across time.*](https://help.github.com/articles/comparing-commits-across-time)
@@ -103,11 +121,17 @@ https://github.com/user/repo/compare/{foreign-user}:{branch}...{own-branch}
For example:
```
https://github.com/rails/rails/compare/byroot:idempotent-counter-caches...master
https://github.com/rails/rails/compare/byroot:master...master
```
![Forked branch compare](http://i.imgur.com/Q1W6qcB.png)
### Gists
[Gists](https://gist.github.com/) 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](https://gist.github.com/tiimgreen/10545817.pibb)) in order to get the *HTML only* version suitable for embedding in any other site.
[Gists](https://gist.github.com/) are an easy way to work with small bits of code without creating a fully fledged repository.
![Gist](http://i.imgur.com/VkKI1LC.png?1)
Add `.pibb` to the end of any Gist URL ([like this](https://gist.github.com/tiimgreen/10545817.pibb)) in order to get the *HTML only* version suitable for embedding in any other site.
Gists can be treated as a full repository so they can be cloned like any other:
@@ -120,7 +144,11 @@ $ git clone https://gist.github.com/tiimgreen/10545817
[*Read more about creating gists.*](https://help.github.com/articles/creating-gists)
### Git.io
[Git.io](http://git.io) is a simple URL shortener for GitHub. You can also use it via pure HTTP using Curl:
[Git.io](http://git.io) is a simple URL shortener for GitHub.
![Git.io](http://i.imgur.com/6JUfbcG.png?1)
You can also use it via pure HTTP using Curl:
```bash
$ curl -i http://git.io -F "url=https://github.com/..."
@@ -143,7 +171,9 @@ When on a repository page, keyboard shortcuts allow you to navigate easily.
- Pressing `l` will edit labels on existing Issues.
- Pressing `y` **when 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 `?`.
To see all of the shortcuts for the current page press `?`:
![Keyboard shortcuts](http://i.imgur.com/y5ZfNEm.png)
[*Read more about using the Command Bar.*](https://help.github.com/articles/using-the-command-bar)
@@ -178,6 +208,13 @@ To link to an issue in another repository, `user_name/repo_name#ISSUE_NUMBER` e.
![Cross-Link Issues](https://camo.githubusercontent.com/447e39ab8d96b553cadc8d31799100190df230a8/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f7265666572656e6365732e706e67)
### CI Status on Pull Requests
If set up correctly, every time you receive a Pull Request, [Travis CI](https://travis-ci.org/) will build that Pull Request just like it would every time you make a new commit. Read more about how to [get started with Travis CI](http://docs.travis-ci.com/user/getting-started/).
[![Travic CI status](https://cloud.githubusercontent.com/assets/1687642/2700187/3a88838c-c410-11e3-9a46-e65e2a0458cd.png)](https://github.com/octokit/octokit.rb/pull/452)
[*Read more about the commit status API.*](https://github.com/blog/1227-commit-status-api)
### Syntax Highlighting in Markdown Files
For example, to syntax highlight Ruby code in your Markdown files write:
@@ -212,7 +249,7 @@ Would produce:
:smile:
The full list of supported Emojis on GitHub can be found [here](http://www.emoji-cheat-sheet.com/) or [here](https://github.com/scotch-io/All-Github-Emoji-Icons).
The full list of supported Emojis on GitHub can be found at [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com/) or [scotch-io/All-Github-Emoji-Icons](https://github.com/scotch-io/All-Github-Emoji-Icons).
The top 5 used Ejmojis on GitHub are:
@@ -302,7 +339,7 @@ Within Jekyll pages and posts, repository information is available within the `s
The Jemoji and jekyll-mentions plugins enable [emoji](#emojis) and [@mentions](https://github.com/blog/821) in your Jekyll posts and pages to work just like you'd expect when interacting with a repository on GitHub.com.
[*Read more about repository metadata and plugin support for GitHub Pages.*](Repository metadata and plugin support for GitHub Pages)
[*Read more about repository metadata and plugin support for GitHub Pages.*](https://github.com/blog/1797-repository-metadata-and-plugin-support-for-github-pages)
### Diffs
#### Rendered Prose Diffs
@@ -330,6 +367,37 @@ Using the *unfold* button in the gutter of a diff, you can reveal additional lin
[*Read more about expanding context in diffs.*](https://github.com/blog/1705-expanding-context-in-diffs)
#### Diff or Patch of Pull Request
You can get the diff of a Pull Request by adding a `.diff` or `.patch`
extension to the end of the URL. For example:
```
https://github.com/tiimgreen/github-cheat-sheet/pull/15
https://github.com/tiimgreen/github-cheat-sheet/pull/15.diff
https://github.com/tiimgreen/github-cheat-sheet/pull/15.patch
```
The `.diff` extension would give you this in plain text:
```
diff --git a/README.md b/README.md
index 88fcf69..8614873 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i
- [Merged Branches](#merged-branches)
- [Quick Licensing](#quick-licensing)
- [TODO Lists](#todo-lists)
+- [Relative Links](#relative-links)
- [.gitconfig Recommendations](#gitconfig-recommendations)
- [Aliases](#aliases)
- [Auto-correct](#auto-correct)
@@ -381,6 +382,19 @@ When they are clicked, they will be updated in the pure Markdown:
- [ ] Sleep
(...)
```
### Hub
[Hub](https://github.com/github/hub) is a command line Git wrapper that gives you extra features and commands that make working with GitHub easier.
@@ -339,12 +407,6 @@ This allows you to do things like:
$ hub clone tiimgreen/toc
```
...instead of:
```bash
$ git clone https://github.com/tiimgreen/toc.git
```
[*Check out some more cool commands Hub has to offer.*](https://github.com/github/hub#commands)
### Decreasing Contributor Friction
@@ -361,6 +423,24 @@ Adding a `CONTRIBUTING` file to the root of your repository will add a link to y
[*Read more about contributing guidelines.*](https://github.com/blog/1184-contributing-guidelines)
### GitHub Resources
| Title | Link |
| ----- | ---- |
| GitHub Explore | https://github.com/explore |
| GitHub Blog | https://github.com/blog |
| GitHub Help | https://help.github.com/ |
| GitHub Training | http://training.github.com/ |
| GitHub Developer | https://developer.github.com/ |
#### GitHub Talks
| Title | Link |
| ----- | ---- |
| How GitHub Uses GitHub to Build GitHub | https://www.youtube.com/watch?v=qyz3jkOBbQY |
| Introduction to Git with Scott Chacon of GitHub | https://www.youtube.com/watch?v=ZDR433b0HJY |
| How GitHub No Longer Works | https://www.youtube.com/watch?v=gXD1ITW7iZI |
| Git and GitHub Secrets | https://www.youtube.com/watch?v=Foz9yvMkvlA |
| More Git and GitHub Secrets | https://www.youtube.com/watch?v=p50xsL-iVgU |
## Git
### Previous Branch
To move to the previous branch in Git:
@@ -378,6 +458,21 @@ $ git checkout -
[*Read more about Git branching.*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging)
### Stripspace
Git Stripspace:
- Strips trailing whitespace
- Collapses newlines
- Adds newline to end of file
A file must be passed when calling the command, e.g.:
```bash
$ git stripspace < README.md
```
[*Read more about the Git `stripspace` command.*](http://git-scm.com/docs/git-stripspace)
### Checking out Pull Requests
If you want to check out pull request locally, you can fetch it using that command:
@@ -603,3 +698,29 @@ $ git config --global color.ui 1
```
[*Read more about the Git `config` command.*](http://git-scm.com/docs/git-config)
### Git Resources
| Title | Link |
| ----- | ---- |
| Official Git Site | http://git-scm.com/ |
| Official Git Video Tutorials | http://git-scm.com/videos |
| Code School Try Git | http://try.github.com/ |
| Introductory Reference & Tutorial for Git | http://gitref.org/ |
| Official Git Tutorial | http://git-scm.com/docs/gittutorial |
| Everyday Git | http://git-scm.com/docs/everyday |
| Git Immersion | http://gitimmersion.com/ |
| Ry's Git Tutorial | http://rypress.com/tutorials/git/index.html |
| Git for Designer | http://hoth.entp.com/output/git_for_designers.html |
| Git for Computer Scientists | http://eagain.net/articles/git-for-computer-scientists/ |
| Git Magic | http://www-cs-students.stanford.edu/~blynn/gitmagic/ |
#### Git Books
| Title | Link |
| ----- | ---- |
| Pragmatic Version Control Using Git | http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git |
| Pro Git | http://git-scm.com/book |
| Git Internals Peepcode | http://peepcode.com/products/git-internals-pdf |
| Git in the Trenches | http://cbx33.github.com/gitt/ |
| Version Control with Git | http://www.amazon.com/Version-Control-Git-collaborative-development/dp/1449316387 |
| Pragmatic Guide to Git | http://www.pragprog.com/titles/pg_git/pragmatic-guide-to-git |
| Git: Version Control for Everyone | http://www.packtpub.com/git-version-control-for-everyone/book |