From 307aa0001fa751988c1d0c41a89cdb38c48438fb Mon Sep 17 00:00:00 2001 From: Bernhard Millauer Date: Sun, 13 Apr 2014 23:35:56 +0200 Subject: [PATCH 01/16] Added cross repo comparision --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 88fcf69..5ebbc43 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,19 @@ https://github.com/rails/rails/compare/master@{2014-10-04}...master ``` which allows you to see the difference on the master branch up a set time ago or a specified date. +### Compare branches cross 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} +``` + +eg.: +``` +https://github.com/rails/rails/compare/byroot:idempotent-counter-caches...master +``` + ## Line Highlighting in Repos Either adding `#L52` to the end of a code file URL or simply clicking the lin number will highlight that line number. From def073ea840c8d8a4f6d0e747dfb29f19668b54b Mon Sep 17 00:00:00 2001 From: "Daniel W. Crompton" Date: Mon, 14 Apr 2014 00:06:25 +0200 Subject: [PATCH 02/16] Update README.md As this only works on the master branch this should be made clear. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88fcf69..fa1706c 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ To see all of the shortcuts for the current page press `?`. ## Closing Issues with Commits -If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed` or `close/closes/closed`, followed by the issue number, will close the issue. +If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed` or `close/closes/closed`, followed by the issue number, will close the issue once it is commited to the master branch. ```bash $ git commit -m "Fix cock up, fixes #12" From fad85aea07af9388104e2a99cfb9219a94c9796b Mon Sep 17 00:00:00 2001 From: Dennis Ideler Date: Sun, 13 Apr 2014 19:31:55 -0400 Subject: [PATCH 03/16] Fix minor typo lin -> line --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88fcf69..344bbb6 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ which allows you to see the difference on the master branch up a set time ago or ## Line Highlighting in Repos -Either adding `#L52` to the end of a code file URL or simply clicking the lin number will highlight that line number. +Either adding `#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: From 5ceb541bd842a96dbcd6292f2134eb5a9a7a0f67 Mon Sep 17 00:00:00 2001 From: Dennis Ideler Date: Sun, 13 Apr 2014 18:39:40 -0400 Subject: [PATCH 04/16] Add section on relative links in markdown Recommend the use of relative links over absolute links when linking to internal content. --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 ``` +## Relative Links + +[Relative links](https://help.github.com/articles/relative-links-in-readmes) are recommended in your Markdown files when linking to internal content. + +```markdown +[Link to a header](#awesome-section) + +[Link to a file](docs/readme) +``` + +Absolute links have to be updated whenever the URL changes (e.g. repo renamed, username changed, project forked). +Using relative links makes your documentation easily stand on its own. + ## .gitconfig Recommendations Your `.gitconfig` is the file that contains all your preferences. From 863d0e19beccb85714f6902a643278f31f97b2d1 Mon Sep 17 00:00:00 2001 From: Matias Singers Date: Mon, 14 Apr 2014 10:37:18 +0800 Subject: [PATCH 05/16] Add Git aliases for tags, branches and remotes Taken from @mathiasbynens dotfiles: https://github.com/mathiasbynens/dotfiles/blob/master/.gitconfig --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 88fcf69..5b61154 100644 --- a/README.md +++ b/README.md @@ -396,6 +396,10 @@ To add an alias, either navigate to `~/.gitconfig` and fill it out in the follow co = checkout cm = commit p = push + # Show verbose output about tags, branches or remotes + tags = tag -l + branches = branch -a + remotes = remote -v ``` or type in the command line: @@ -421,6 +425,9 @@ Some recommendations include: | `git co` | `git checkout` | `git config --global alias.co checkout` | | `git ac` | `git add . -A` `git commit` | `git config --global alias.ac '!git add -A && git commit'` | | `git st` | `git status -sb` | `git config --global alias.st 'status -sb'` | +| `git tags` | `git tag -l` | `git config --global alias.tags 'tag -l'` | +| `git branches` | `git branch -a` | `git config --global alias.branches 'branch -a'` | +| `git remotes` | `git remote -v` | `git config --global alias.remotes 'remote -v'` | ### Auto-correct From f0d3e503a84ee498d735277212f48ef326bfccd6 Mon Sep 17 00:00:00 2001 From: Bernhard Millauer Date: Mon, 14 Apr 2014 09:58:59 +0200 Subject: [PATCH 06/16] Fixed a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ebbc43..823c5c3 100644 --- a/README.md +++ b/README.md @@ -235,7 +235,7 @@ https://github.com/rails/rails/compare/master@{2014-10-04}...master ``` which allows you to see the difference on the master branch up a set time ago or a specified date. -### Compare branches cross forked repositories +### Compare branches across forked repositories To use GitHub to compare branches across forked repositories, change the URL to look like this: From 9886100f08c93f1acefe88d654eb87e86865dd96 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 10:36:59 +0100 Subject: [PATCH 07/16] Add label hotkey (fixes #19) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ddc50c8..43275aa 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ Pressing `w` will bring up the branch selector. Pressing `s` will select the search bar. +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 `?`. From e70c204e3d7cb154f5866b575d01c1da14b68a6c Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 12:37:57 +0100 Subject: [PATCH 08/16] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bc494e..40022d2 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ To see all of the shortcuts for the current page press `?`. ## Closing Issues with Commits -If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed` or `close/closes/closed`, followed by the issue number, will close the issue once it is commited to the master branch. +If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed` or `close/closes/closed`, followed by the issue number, will close the issue once it is committed to the master branch. ```bash $ git commit -m "Fix cock up, fixes #12" From 1b5e9c949d1eefac92cce12502494d75b0a010fb Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 13:12:26 +0100 Subject: [PATCH 09/16] Add links to docs --- README.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 40022d2..90512db 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i Adding `?w=1` to any diff URL will remove any changes only in whitespace, enabling you to see only that code that has changed. +[*Read more about GitHub secrets.*](https://github.com/blog/967-github-secrets) + ## Cloning a Repo When cloning a repo the `.git` can be left off the end. @@ -46,6 +48,8 @@ When cloning a repo the `.git` can be left off the end. $ git clone https://github.com/tiimgreen/github-cheat-sheet ``` +[*Read more about the Git `clone` command.*](http://git-scm.com/docs/git-clone) + ## Hub - Git Wrapper [Hub](https://github.com/github/hub) is a command line git wrapper that gives extra features and commands that make working with GitHub easier. @@ -83,12 +87,16 @@ $ git checkout - # Switched to branch 'master' ``` +[*Read more about Git branching.*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging) + ## git.io [git.io](http://git.io) is a simple URL shortener for GitHub. [http://git.io/wO0xUg](http://git.io/wO0xUg) +[*Read more about Git.io.*](https://github.com/blog/985-git-io-github-url-shortener) + ## Gists [Gists](https://gist.github.com/) are an easy way to work with small bits of code without creating a fully fledged repo. @@ -100,6 +108,8 @@ $ git clone https://gist.github.com/tiimgreen/10545817 ![Gists](http://i.imgur.com/dULZXXo.png) +[*Read more about creating gists.*](https://help.github.com/articles/creating-gists) + ## Keyboard Shortcuts When on a repo page keyboard shortcuts allow you to navigate easily. @@ -116,6 +126,8 @@ Pressing `y` __when looking at a file__ (e.g. `https://github.com/tiimgreen/gith To see all of the shortcuts for the current page press `?`. +[*Read more about using the Command Bar.*](https://help.github.com/articles/using-the-command-bar) + ## Closing Issues with Commits If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed` or `close/closes/closed`, followed by the issue number, will close the issue once it is committed to the master branch. @@ -128,6 +140,8 @@ This closes the issue and references the closing commit. ![Closing Repo](http://i.imgur.com/URXFprQ.png) +[*Read more about closing issues via commit messages.*](https://help.github.com/articles/closing-issues-via-commit-messages) + ## Checking out Pull Requests If you want to check out pull request locally, you can fetch it using that command: @@ -170,6 +184,8 @@ and even fetch them automatically, if you add corresponding lines in your .git/c fetch = +refs/pull/*/head:refs/remotes/origin/pr/* ``` +[*Read more about checking out pull requests locally.*](https://help.github.com/articles/checking-out-pull-requests-locally) + ## Cross-link Issues If you want to link to another issue in the same repo, simple type hash `#` then the issue number, it will be auto-linked. @@ -198,6 +214,8 @@ puts table.to_s GitHub uses [Linguist](https://github.com/github/linguist) to perform language detection and syntax highlighting. You can find out which keywords are valid by perusing the [languages YAML file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). +[*Read more about GitHub Flavored Markdown.*](https://help.github.com/articles/github-flavored-markdown) + ## Commit History by Author To view all commits on a repo by author add `?author=username` to the URL. @@ -206,6 +224,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 ``` +[*Read more about the differences between commits views.*](https://help.github.com/articles/differences-between-commit-views) + ## Empty Commits Commits can be pushed with no code changes by adding `--allow-empty` @@ -238,6 +258,8 @@ https://github.com/rails/rails/compare/master@{2014-10-04}...master ``` 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) + ### Compare branches across forked repositories To use GitHub to compare branches across forked repositories, change the URL to look like this: @@ -307,6 +329,8 @@ When on a comment thread and you want to quote something someone previously said ![Quick Quote](http://i.imgur.com/TzpMIOA.png) +[*Read more about quick quoting.*](https://github.com/blog/1399-quick-quotes) + ## Styled Git Status ```bash @@ -323,6 +347,8 @@ $ git status -sb ![git status -sb](http://i.imgur.com/xNI1bT0.png) +[*Read more about the Git `status` command.*](http://git-scm.com/docs/git-status) + ## Styled Git Log ```bash @@ -333,6 +359,8 @@ $ git log --all --graph --decorate --oneline --abbrev-commit NOTE: This can be added into an Alias (shorter command) using the instructions [here](https://github.com/tiimgreen/github-cheat-sheet#aliases) +[*Read more about the Git `log` command.*](http://git-scm.com/docs/git-log) + ## Git Query A git query allows you to search all your previous commit messages and finds the most recent one matching the query. @@ -366,6 +394,8 @@ $ git branch --no-merged Will give you a list of branches that have not been merged into your current branch. +[*Read more about the Git `branch` command.*](http://git-scm.com/docs/git-branch) + ## Quick Licensing When creating a repo GitHub gives you the options of adding in a pre-made license: @@ -378,6 +408,8 @@ You can also add them to existing repos by creating a new file through the web i Also works for `.gitignore`. +[*Read more about open source licensing.*](https://help.github.com/articles/open-source-licensing) + ## TODO Lists In Issues and Pull requests check boxes can be added with the following syntax (notice the space): @@ -397,9 +429,11 @@ When they are clicked, they will be updated in the pure Markdown: - [ ] Sleep ``` +[*Read more about task lists.*](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) + ## Relative Links -[Relative links](https://help.github.com/articles/relative-links-in-readmes) are recommended in your Markdown files when linking to internal content. +Relative links are recommended in your Markdown files when linking to internal content. ```markdown [Link to a header](#awesome-section) @@ -410,6 +444,8 @@ When they are clicked, they will be updated in the pure Markdown: Absolute links have to be updated whenever the URL changes (e.g. repo renamed, username changed, project forked). Using relative links makes your documentation easily stand on its own. +[*Read more about relative links.*](https://help.github.com/articles/relative-links-in-readmes) + ## .gitconfig Recommendations Your `.gitconfig` is the file that contains all your preferences. @@ -492,6 +528,8 @@ To add more colour to your git command line: $ git config --global color.ui 1 ``` +[*Read more about the Git `config` command.*](http://git-scm.com/docs/git-config) + # Sharing Share on [Twitter](https://twitter.com/intent/tweet?source=webclient&text=http%3A%2F%2Fgithub.com%2Ftiimgreen%2Fgithub-cheat-sheet%20-%20GitHub%20Cheat%20Sheet) From 3d1d9a5cbc38bf33b54521c1faf1161cf8c154a3 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 13:28:48 +0100 Subject: [PATCH 10/16] Add Friction example --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 90512db..3eb433e 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i - [Ignore Whitespace](#ignore-whitespace) - [Cloning a Repo](#cloning-a-repo) - [Hub - Git Wrapper](#hub---git-wrapper) +- [Decreasing Contributor Friction](#decreasing-contributor-friction) - [Previous Branch](#previous-branch) - [git.io](#gitio) - [Gists](#gists) @@ -66,6 +67,13 @@ instead of: $ git clone https://github.com/tiimgreen/toc.git ``` +## Decreasing Contributor Friction +If you want people to use and contribute to your project, you need to start by answering their most basic questions. What does the project do? How do I use it? How am I allowed to use it? How do I contribute? How do I get up and running in development? How do I make sure my new features didn't break old functionality? + +[Friction](https://github.com/rafalchmiel/friction) is a command line script that will check your project for common answers to these questions. This is some example output: + +[![Friction output](http://i.imgur.com/4EgpWo4.png)](https://github.com/rafalchmiel/friction) + ## Previous Branch To move to the previous directory in the command line: From cfcb044ded8b5d59238aeb385eef480f3d8a9fc1 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 14:04:53 +0100 Subject: [PATCH 11/16] :cat: + :rabbit: = sweeter than Chuck Norris --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3eb433e..2c63d11 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,7 @@ Images and GIFs can be added to comments, READMEs etc.: ![Alt Text](http://image_url.com/image.jpg) ``` -![Chuck Norris](http://gifs.joelglovier.com/chuck-norris/chuck-norris.gif) +![Cat and Rabbit](http://i.imgur.com/PoBmL0W.gif) All images are cached on GitHub, so if your host goes down, the image will remain available. From 04654237494041204028876cfdb36338c8e3cb20 Mon Sep 17 00:00:00 2001 From: Tim Green Date: Mon, 14 Apr 2014 14:10:22 +0100 Subject: [PATCH 12/16] Update git query Image --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c63d11..25e910b 100644 --- a/README.md +++ b/README.md @@ -382,7 +382,7 @@ Where `query` is the term you want to search, this then finds the last one and g ```bash $ git show :/typo ``` -![git show :/query](http://i.imgur.com/SA0oZbE.png) +![git show :/query](http://i.imgur.com/icaGiNt.png) NOTE: Press `q` to quit. From bc9f34a0760d07d3e771563ff57a535f6cb01f12 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 14:23:53 +0100 Subject: [PATCH 13/16] Add link to Hub commands docs --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 25e910b..189ab7a 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ instead of: $ 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 If you want people to use and contribute to your project, you need to start by answering their most basic questions. What does the project do? How do I use it? How am I allowed to use it? How do I contribute? How do I get up and running in development? How do I make sure my new features didn't break old functionality? From 18694b1718c6e27f1a0d5da43e18eaecbde95430 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 14:26:05 +0100 Subject: [PATCH 14/16] It's 'Task Lists' not 'TODO Lists' --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 189ab7a..fecd89d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i - [Git Query](#git-query) - [Merged Branches](#merged-branches) - [Quick Licensing](#quick-licensing) -- [TODO Lists](#todo-lists) +- [Task Lists](#task-lists) - [Relative Links](#relative-links) - [.gitconfig Recommendations](#gitconfig-recommendations) - [Aliases](#aliases) @@ -420,7 +420,7 @@ Also works for `.gitignore`. [*Read more about open source licensing.*](https://help.github.com/articles/open-source-licensing) -## TODO Lists +## Task Lists In Issues and Pull requests check boxes can be added with the following syntax (notice the space): ``` @@ -429,7 +429,7 @@ In Issues and Pull requests check boxes can be added with the following syntax ( - [ ] Sleep ``` -![TODO List](http://i.imgur.com/k2qZi56.png) +![Task List](http://i.imgur.com/k2qZi56.png) When they are clicked, they will be updated in the pure Markdown: From 46be82be05b730609f156a6b8aad76a367578509 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 14:28:09 +0100 Subject: [PATCH 15/16] Use GIF for quick quoting example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fecd89d..44f1201 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,7 @@ All images are cached on GitHub, so if your host goes down, the image will remai When on a comment thread and you want to quote something someone previously said, highlight the text and press `r`, this will copy it into your text box in the block-quote format. -![Quick Quote](http://i.imgur.com/TzpMIOA.png) +![Quick Quote](https://f.cloud.github.com/assets/296432/124483/b0fa6204-6ef0-11e2-83c3-256c37fa7abc.gif) [*Read more about quick quoting.*](https://github.com/blog/1399-quick-quotes) From 19e0038601a3059e9ff71a4af482e2f2b4b38293 Mon Sep 17 00:00:00 2001 From: Rafal Chmiel Date: Mon, 14 Apr 2014 14:36:05 +0100 Subject: [PATCH 16/16] Add section on repository metadata and plugin support for GitHub Pages --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 44f1201..5b077d5 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i - [Empty Commits](#empty-commits) - [Comparing Branches](#comparing-branches) - [Line Highlighting in Repos](#line-highlighting-in-repos) +- [Metadata and Plugin Support for GitHub Pages](#metadata-and-plugin-support-for-github-pages) - [Emojis](#emojis) - [Images/GIFs](#imagesgifs) - [Quick Quoting](#quick-quoting) @@ -295,6 +296,13 @@ https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L ![Line Highlighting](http://i.imgur.com/8AhjrCz.png) +## Metadata and Plugin Support for GitHub Pages +Within Jekyll pages and posts, repository information is available within the `site.github` namespace, and can be displayed, for example, using `{{ site.github.project_title }}`. + +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) + ## Emojis Emojis can be generated on Pull Requests, Issues, Commit Messages, READMEs, etc. using `:name_of_emoji:`