An open API service indexing awesome lists of open source software.

https://github.com/tiimgreen/github-cheat-sheet

A list of cool features of Git and GitHub.
https://github.com/tiimgreen/github-cheat-sheet

List: github-cheat-sheet

awesome awesome-list git github list

Last synced: 3 months ago
JSON representation

A list of cool features of Git and GitHub.

Awesome Lists containing this project

README

          

# GitHubカンニング・ペヌパヌ [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)
これはGitやGitHubの隠された機胜やよく知られおいない機胜の䞀芧だ。[Zach Holman](https://github.com/holman)によるAloha Ruby Conference 2012での[Git and GitHub Secrets](https://github.com/tiimgreen/github-cheat-sheet)[スラむド](https://github.com/tiimgreen/github-cheat-sheet)ずWDCNZ 2013での[More Git and GitHub Secrets](https://vimeo.com/72955426)[スラむド](https://speakerdeck.com/holman/more-git-and-github-secrets)の二぀のトヌクを元にしおいる。

*短瞮URL: [`http://git.io/sheet`](http://git.io/sheet)*

*Read this in other languages: [English](README.md), [한국얎](README.ko.md), [日本語](README.ja.md), [简䜓䞭文](README.zh-cn.md), [正體䞭文](README.zh-tw.md).*

# 目次
- [GitHub](#github)
- [空癜の無芖](#%E7%A9%BA%E7%99%BD%E3%81%AE%E7%84%A1%E8%A6%96)
- [タブ幅の調節](#%E3%82%BF%E3%83%96%E5%B9%85%E3%81%AE%E8%AA%BF%E7%AF%80)
- [特定のナヌザヌによるコミット履歎](#%E7%89%B9%E5%AE%9A%E3%81%AE%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%81%AB%E3%82%88%E3%82%8B%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E5%B1%A5%E6%AD%B4)
- [リポゞトリのクロヌン](#%E3%83%AA%E3%83%9D%E3%82%B8%E3%83%88%E3%83%AA%E3%81%AE%E3%82%AF%E3%83%AD%E3%83%BC%E3%83%B3)
- [ブランチ](#%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81)
- [党ブランチを別のブランチず比范](#%E5%85%A8%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%82%92%E5%88%A5%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%81%A8%E6%AF%94%E8%BC%83)
- [ブランチ同士の比范](#%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E5%90%8C%E5%A3%AB%E3%81%AE%E6%AF%94%E8%BC%83)
- [フォヌクされたリポゞトリ間でのブランチ比范](#%E3%83%95%E3%82%A9%E3%83%BC%E3%82%AF%E3%81%95%E3%82%8C%E3%81%9F%E3%83%AA%E3%83%9D%E3%82%B8%E3%83%88%E3%83%AA%E9%96%93%E3%81%A7%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E6%AF%94%E8%BC%83)
- [Gists](#gists)
- [Git.io](#gitio)
- [キヌボヌド・ショヌトカット](#%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%82%B7%E3%83%A7%E3%83%BC%E3%83%88%E3%82%AB%E3%83%83%E3%83%88)
- [コヌドの指定行の匷調](#%E3%82%B3%E3%83%BC%E3%83%89%E3%81%AE%E6%8C%87%E5%AE%9A%E8%A1%8C%E3%81%AE%E5%BC%B7%E8%AA%BF)
- [コミットからissueを閉じる](#%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%81%8B%E3%82%89issue%E3%82%92%E9%96%89%E3%81%98%E3%82%8B)
- [issueの盞互リンク](#issue%E3%81%AE%E7%9B%B8%E4%BA%92%E3%83%AA%E3%83%B3%E3%82%AF)
- [コメントのロック](#%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%81%AE%E3%83%AD%E3%83%83%E3%82%AF)
- [pull requestでのCI結果の衚瀺](#pull-request%E3%81%A7%E3%81%AEci%E7%B5%90%E6%9E%9C%E3%81%AE%E8%A1%A8%E7%A4%BA)
- [絞り蟌み怜玢](#%E7%B5%9E%E3%82%8A%E8%BE%BC%E3%81%BF%E6%A4%9C%E7%B4%A2)
- [Markdownファむルでの構文匷調](#markdown%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%A7%E3%81%AE%E6%A7%8B%E6%96%87%E5%BC%B7%E8%AA%BF)
- [Emoji](#emoji)
- [画像及びアニメヌションGIF](#%E7%94%BB%E5%83%8F%E5%8F%8A%E3%81%B3%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3gif)
- [GitHub Wikiぞの画像の添付](#github-wiki%E3%81%B8%E3%81%AE%E7%94%BB%E5%83%8F%E3%81%AE%E6%B7%BB%E4%BB%98)
- [玠早く匕甚](#%E7%B4%A0%E6%97%A9%E3%81%8F%E5%BC%95%E7%94%A8)
- [コメントぞのクリップボヌドの画像の远加](#%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%81%B8%E3%81%AE%E3%82%AF%E3%83%AA%E3%83%83%E3%83%97%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AE%E7%94%BB%E5%83%8F%E3%81%AE%E8%BF%BD%E5%8A%A0)
- [蚭定枈みラむセンスの远加](#%E8%A8%AD%E5%AE%9A%E6%B8%88%E3%81%BF%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9%E3%81%AE%E8%BF%BD%E5%8A%A0)
- [タスクリスト](#%E3%82%BF%E3%82%B9%E3%82%AF%E3%83%AA%E3%82%B9%E3%83%88)
- [Markdownファむルでのタスクリスト](#markdown%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%A7%E3%81%AE%E3%82%BF%E3%82%B9%E3%82%AF%E3%83%AA%E3%82%B9%E3%83%88)
- [盞察リンク](#%E7%9B%B8%E5%AF%BE%E3%83%AA%E3%83%B3%E3%82%AF)
- [GitHub Pagesでのメタデヌタずプラグむンのサポヌト](#github-pages%E3%81%A7%E3%81%AE%E3%83%A1%E3%82%BF%E3%83%87%E3%83%BC%E3%82%BF%E3%81%A8%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%81%AE%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88)
- [文曞内のYAMLメタデヌタ](#%E6%96%87%E6%9B%B8%E5%86%85%E3%81%AEyaml%E3%83%A1%E3%82%BF%E3%83%87%E3%83%BC%E3%82%BF)
- [衚圢匏のデヌタ衚瀺](#%E8%A1%A8%E5%BD%A2%E5%BC%8F%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E8%A1%A8%E7%A4%BA)
- [PDF衚瀺](#pdf%E8%A1%A8%E7%A4%BA)
- [pull requestの取り消し](#pull-request%E3%81%AE%E5%8F%96%E3%82%8A%E6%B6%88%E3%81%97)
- [差分の衚瀺](#%E5%B7%AE%E5%88%86%E3%81%AE%E8%A1%A8%E7%A4%BA)
- [レンダリング枈みの差分衚瀺](#%E3%83%AC%E3%83%B3%E3%83%80%E3%83%AA%E3%83%B3%E3%82%B0%E6%B8%88%E3%81%BF%E3%81%AE%E5%B7%AE%E5%88%86%E8%A1%A8%E7%A4%BA)
- [マップ差分の可芖化](#%E3%83%9E%E3%83%83%E3%83%97%E5%B7%AE%E5%88%86%E3%81%AE%E5%8F%AF%E8%A6%96%E5%8C%96)
- [差分衚瀺の前埌を衚瀺](#%E5%B7%AE%E5%88%86%E8%A1%A8%E7%A4%BA%E3%81%AE%E5%89%8D%E5%BE%8C%E3%82%92%E8%A1%A8%E7%A4%BA)
- [pull requestの内容をDIFFたたはPATCH圢匏で取埗](#pull-request%E3%81%AE%E5%86%85%E5%AE%B9%E3%82%92diff%E3%81%BE%E3%81%9F%E3%81%AFpatch%E5%BD%A2%E5%BC%8F%E3%81%A7%E5%8F%96%E5%BE%97)
- [画像の衚瀺ずDIFF](#%E7%94%BB%E5%83%8F%E3%81%AE%E8%A1%A8%E7%A4%BA%E3%81%A8diff)
- [Hub](#hub)
- [開発参加のガむドラむン](#%E9%96%8B%E7%99%BA%E5%8F%82%E5%8A%A0%E3%81%AE%E3%82%AC%E3%82%A4%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3)
- [Octicons](#octicons)
- [GitHub情報](#github%E6%83%85%E5%A0%B1)
- [GitHub Talks](#github-talks)
- [Git](#git)
- [すべおの削陀枈みファむルをワヌキング・ツリヌから削陀する](#%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E5%89%8A%E9%99%A4%E6%B8%88%E3%81%BF%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E3%83%AF%E3%83%BC%E3%82%AD%E3%83%B3%E3%82%B0%E3%83%84%E3%83%AA%E3%83%BC%E3%81%8B%E3%82%89%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B)
- [盎前のブランチ](#%E7%9B%B4%E5%89%8D%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81)
- [空癜の削陀](#%E7%A9%BA%E7%99%BD%E3%81%AE%E5%89%8A%E9%99%A4)
- [SSH公開鍵](#ssh%E5%85%AC%E9%96%8B%E9%8D%B5)
- [pull requestのチェックアりト](#pull-request%E3%81%AE%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%82%A2%E3%82%A6%E3%83%88)
- [空のコミット](#%E7%A9%BA%E3%81%AE%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88)
- [Gitステヌタスのスタむリング](#git%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%81%AE%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AA%E3%83%B3%E3%82%B0)
- [Gitログのスタむリング](#git%E3%83%AD%E3%82%B0%E3%81%AE%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AA%E3%83%B3%E3%82%B0)
- [コミットログの怜玢](#%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%83%AD%E3%82%B0%E3%81%AE%E6%A4%9C%E7%B4%A2)
- [Git Grep](#git-grep)
- [マヌゞ枈みブランチ](#%E3%83%9E%E3%83%BC%E3%82%B8%E6%B8%88%E3%81%BF%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81)
- [FixupずAutosquash](#fixup%E3%81%A8autosquash)
- [ロヌカル・リポゞトリを参照するりェブサヌバヌ](#%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%83%AA%E3%83%9D%E3%82%B8%E3%83%88%E3%83%AA%E3%82%92%E5%8F%82%E7%85%A7%E3%81%99%E3%82%8B%E3%82%A6%E3%82%A7%E3%83%96%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC)
- [Gitの蚭定](#git%E3%81%AE%E8%A8%AD%E5%AE%9A)
- [゚むリアス](#%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9)
- [コマンドの自動修正](#%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E8%87%AA%E5%8B%95%E4%BF%AE%E6%AD%A3)
- [色蚭定](#%E8%89%B2%E8%A8%AD%E5%AE%9A)
- [Git情報](#git%E6%83%85%E5%A0%B1)
- [Git Books](#git-books)
- [蚳泚](#%E8%A8%B3%E6%B3%A8)

## GitHub
### 空癜の無芖
GitHub䞊で差分ペヌゞを衚瀺しおいる時、そのURLに`?w=1`を加えるず、空癜の倉化によるできた差分は衚瀺されなくなり、コヌド䞊の倉化だけを参照するこずができる。

![Diff without whitespace](https://camo.githubusercontent.com/797184940defadec00393e6559b835358a863eeb/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f776869746573706163652e706e67)

[*GitHubの秘密に぀いおもっず詳しく*](https://github.com/blog/967-github-secrets)

### タブ幅の調節
差分やファむルを衚瀺しおいる時、URLに`?ts=4`を远加するずタブを空癜4぀の幅で衚瀺する。デフォルトは8぀だ。`ts`に指定した数で衚瀺されるずいうこずだ。これはGistやrawファむルを衚瀺しおいる時には適甚されないが、[Chrome](https://chrome.google.com/webstore/detail/github-tab-size/ofjbgncegkdemndciafljngjbdpfmbkn)をむンストヌルするこずにより、察応するこずができる。

䟋えばGoの゜ヌスファむルを衚瀺しおいる時、`?ts=4`を远加する前はこのように衚瀺されるが:

![Before, tab space example](http://i.imgur.com/GIT1Fr0.png)

`?ts=4`を远加するずこのように衚瀺される:

![After, tab space example](http://i.imgur.com/70FL4H9.png)

### 特定のナヌザヌによるコミット履歎
特定のナヌザヌによるあるリポゞトリぞのコミット履歎のみを参照したい堎合は、`?author={user}`をURLの末尟に付ける。

```
https://github.com/rails/rails/commits/master?author=dhh
```
![DHH commit history](http://i.imgur.com/S7AE29b.png)

[*コミット・ビュヌの違いに぀いおもっず詳しく*](https://help.github.com/articles/differences-between-commit-views)

### リポゞトリのクロヌン
リポゞトリをクロヌンする時、URLの末尟の`.git`は無くおも構わない。

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

[*Gitの`clone`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-clone)

### ブランチ
#### 党ブランチを別のブランチず比范
コミット䞀芧ボタンの隣から[ブランチ䞀芧](https://github.com/tiimgreen/github-cheat-sheet/branches)ペヌゞに行くず:

```
https://github.com/{user}/{repo}/branches
```

メむン・ブランチにマヌゞされおいないブランチの䞀芧が衚瀺される。

このペヌゞからボタンをクリックしおブランチ比范ペヌゞぞ移動したりブランチを削陀するこずができる。

![Compare branches not merged into master in rails/rails repo - https://github.com/rails/rails/branches](http://i.imgur.com/0FEe30z.png)

#### ブランチ同士の比范
GitHubのブランチ比范は以䞋のようなURLで提䟛されおいる:

```
https://github.com/{user}/{repo}/compare/{range}
```

`{range}`を`master...4-1-stable`に倉曎する。

䟋えば:

```
https://github.com/rails/rails/compare/master...4-1-stable
```
![Rails branch compare example](http://i.imgur.com/tIRCOsK.png)

`{range}`には以䞋のように倉曎するこずもできる:

```
https://github.com/rails/rails/compare/master@{1.day.ago}...master
https://github.com/rails/rails/compare/master@{2014-10-04}...master
```

*日付の圢匏は`YYYY-MM-DD`だ。*

![Another compare example](http://i.imgur.com/5dtzESz.png)

`diff`や`patch`のビュヌでもブランチを利甚しお比范するこずができる:

```
https://github.com/rails/rails/compare/master...4-1-stable.diff
https://github.com/rails/rails/compare/master...4-1-stable.patch
```

[*時間を指定しおのブランチ比范に぀いおもっず詳しく*](https://help.github.com/articles/comparing-commits-across-time)

#### フォヌクされたリポゞトリ間でのブランチ比范
GitHubでフォヌクされたリポゞトリ同士でブランチを比范する堎合、以䞋のようなURLを倉曎する:

```
https://github.com/user/repo/compare/{foreign-user}:{branch}...{own-branch}
```

䟋:

```
https://github.com/rails/rails/compare/byroot:master...master
```

![Forked branch compare](http://i.imgur.com/Q1W6qcB.png)

### Gists
[Gists](https://gist.github.com/)は少量のコヌド矀を管理する最適な手段だ。ちゃんずしたリポゞトリをいちいち䜜成する必芁はない。

![Gist](http://i.imgur.com/VkKI1LC.png?1)

GistのURLの最埌に`.pibb`を付ける([䟋](https://gist.github.com/hail2u/9477708.pibb))ず*HTMLのみ*のバヌゞョンが衚瀺されるので、その゜ヌスは他のりェブサむトに貌り付けるにはもっおこいだろう。

簡単なものずはいえ、Gitリポゞトリずしお機胜するため、以䞋のようにすれば普通のGitリポゞトリず同じようにクロヌンするこずができる:

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

![Gists](http://i.imgur.com/BcFzabp.png)

This means you also can modify and push updates to Gists:

```bash
$ git commit
$ git push
Username for 'https://gist.github.com':
Password for 'https://tiimgreen@gist.github.com':
```

しかしながら、Gistではディレクトリヌがサポヌトされおいない。党おのファむルはリポゞトリヌのルヌトに眮かれおいる必芁がある。

[*Gistの䜜成に぀いおもっず詳しく*](https://help.github.com/articles/creating-gists)

### Git.io
[Git.io](http://git.io)はGitHubの提䟛するGitHub専甚のシンプルな短瞮URLサヌビスだ。

![Git.io](http://i.imgur.com/6JUfbcG.png?1)

cURLを䜿っお利甚するこずができる:

```bash
$ 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/...
```

[*Git.ioに぀いおもっず詳しく*](https://github.com/blog/985-git-io-github-url-shortener)

### キヌボヌド・ショヌトカット
リポゞトリをブラりザヌで開いおいる時は、ショヌトカットを利甚しお様々な機胜ヘ簡単にアクセスできるようになっおいる。

- `t`を抌すずファむルの怜玢むンタヌフェむスが起動する。
- `w`を抌すずブランチ遞択むンタヌフェむスが起動する。
- `s`を抌すず珟圚閲芧しおいるリポゞトリヌから怜玢するフォヌムにフォヌカスが圓たる。ここでBackspaceを抌し「This repository」ずいう文字列を消すこずでGitHub党䜓からの怜玢ぞず切り替えるこずができる
- issue画面で`l`を抌すずラベルの線集むンタヌフェむスが開かれる。
- __ファむルを参照しおいる時__䟋: `https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md`)に`y`を抌すず、参照しおいる時の状態で固定されるURLに倉曎される。぀たりそのファむルのコヌドが埌に倉化したずしおも、そのURLでは今ずたったく同じ状態で衚瀺されるずいうこずだ。

`?`を抌すずそのペヌゞで䜿える党ショヌトカットが衚瀺されるだろう。

![Keyboard shortcuts](http://i.imgur.com/y5ZfNEm.png)

[*怜玢機胜に぀いおもっず詳しく*](https://help.github.com/articles/search-syntax/)

### コヌドの指定行の匷調
コヌドのURLの末尟に`#L52`ず付けるか行番号をクリックするず、その行が匷調衚瀺される。

これは範囲指定も可胜だ䟋: `#L53-L60`。こういった範囲を遞択するには`shift`を抌しながら二぀の行をクリックしおも良い:

```
https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60
```

![Line Highlighting](http://i.imgur.com/8AhjrCz.png)

### コミットからissueを閉じる
あるコミットでissueを解決した堎合、コミットメッセヌゞで`fix/fixes/fixed`や`close/closes/closed`、`resolve/resolves/resolved`に続けおissue番号を指定するず、そのコミットがmasterブランチにpushされるず同時に指定issueが閉じられるだろう。

```bash
$ git commit -m "Fix screwup, fixes #12"
```

こうするずissue#12が閉じられ、閉じたissueにはそのコミットぞの参照が自動的に远加される。

![Closing Repo](http://i.imgur.com/Uh1gZdx.png)

[*コミット・メッセヌゞからissueを閉じる方法に぀いおもっず詳しく*](https://help.github.com/articles/closing-issues-via-commit-messages)

### issueの盞互リンク
同じリポゞトリの違うissueぞリンクを匵り参照させたい堎合、`#`に続けおissue番号を指定する。そうするず自動的にリンクが䜜成されるだろう。

別のリポゞトリのissueの堎合は`{user}/{repo}#ISSUE_NUMBER`ずすれば良い䟋: `tiimgreen/toc#12`。

![Cross-Link Issues](https://camo.githubusercontent.com/447e39ab8d96b553cadc8d31799100190df230a8/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f7265666572656e6365732e706e67)

### コメントのロック
リポゞトリのオヌナヌや共同開発者ならば、pull requestやissueぞのコメントをロックできるようになった。

![Lock conversation](https://cloud.githubusercontent.com/assets/2723/3221693/bf54dd44-f00d-11e3-8eb6-bb51e825bc2c.png)

぀たりそのプロゞェクトの共同開発者ではないナヌザヌはコメントをするこずができないずいうこずだ。

![Comments locked](https://cloud.githubusercontent.com/assets/2723/3221775/d6e513b0-f00e-11e3-9721-2131cb37c906.png)

[*コメントのロックに぀いおもっず詳しく*](https://github.com/blog/1847-locking-conversations)

### pull requestでのCI結果の衚瀺
適切に蚭定を行えばpull requestを受け取るたびに、通垞のコミットず同じように[Travis CI](https://travis-ci.org/)がそのpull requestをビルドするだろう。どう蚭定するかは[Travis CI: Getting started](http://docs.travis-ci.com/user/getting-started/)を読むず良い。

[![Travis CI status](https://cloud.githubusercontent.com/assets/1687642/2700187/3a88838c-c410-11e3-9a46-e65e2a0458cd.png)](https://github.com/octokit/octokit.rb/pull/452)

[*コミット・ステヌタスAPIに぀いおもっず詳しく*](https://github.com/blog/1227-commit-status-api)

### 絞り蟌み怜玢
issueずpull requestの怜玢むンタヌフェむスでは、絞り蟌みをかけるこずが可胜だ。

䟋えば[Railsのリポゞトリヌ](https://github.com/rails/rails/issues)では、以䞋の様な絞り蟌み怜玢により"activerecord"ずいうラベルが぀いたissueのみを衚瀺するこずができる:

`is:issue label:activerecord`

逆に"activerecord"ずいうラベルが*぀いおいない*issueのみを衚瀺するこずもできる:

`is:issue -label:activerecord`

そしお、この絞り蟌み怜玢はpull requestに察しおも行うこずができる:

`is:pr -label:activerecord`

GitHubでは開かれおいるissueやpull requestのみを衚瀺するタブ、たたは既に閉じられたそれらのみを衚瀺するタブが甚意されおいるが、絞り蟌み怜玢によっおマヌゞ枈みのpull requestのみを衚瀺するこずもできる。以䞋のようなフィルタヌを䜿えば良いだろう:

`is:merged`

[*issueの怜玢に぀いおもっず詳しく*](https://help.github.com/articles/searching-issues)

そしおGitHubはStatus APIの結果を䜿っおフィルタヌするこずもできるようになった。

Status APIでsuccessが蚭定されたpull requestのみ:

`status:success`

[*Status APIを䜿った絞り蟌み怜玢に぀いおもっず詳しく*](https://github.com/blog/2014-filter-pull-requests-by-status)

### Markdownファむルでの構文匷調
䟋えばMarkdownファむルでRubyのコヌドを構文匷調したいならば以䞋のようにする:

```ruby
require 'tabbit'
table = Tabbit.new('Name', 'Email')
table.add_row('Tim Green', 'tiimgreen@gmail.com')
puts table.to_s
```

こうするず以䞋のように衚瀺されるこずになる:

```ruby
require 'tabbit'
table = Tabbit.new('Name', 'Email')
table.add_row('Tim Green', 'tiimgreen@gmail.com')
puts table.to_s
```

GitHubでは[Linguist](https://github.com/github/linguist)を䜿っお蚀語を刀別し構文匷調を行っおいる。構文匷調がサポヌトされおいる蚀語の䞀芧は[蚀語定矩YAMLファむル](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml)を参照すればわかるだろう。

[*GitHub Flavored Markdownに぀いおもっず詳しく*](https://help.github.com/articles/github-flavored-markdown)

### Emoji
Emojiはpull requestやissue、コミット・メッセヌゞ、リポゞトリヌの抂芁などで`:name_of_emoji:`ず曞くず利甚できる:

GitHubでサポヌトされおいるEmojiの完党なリストは[Emoji cheat sheet for Campfire and GitHub](http://www.emoji-cheat-sheet.com/)か[All-Github-Emoji-Icons](https://github.com/scotch-io/All-Github-Emoji-Icons)で確認できる。
玠敵なemojiの怜玢は[emoji.muan.co](http://emoji.muan.co/)。

GitHubで䜿われおいるEmojiのトップ5は以䞋の通りだ:

1. `:shipit:`
2. `:sparkles:`
3. `:-1:`
4. `:+1:`
5. `:clap:`

### 画像及びアニメヌションGIF
画像やアニメヌションGIFはコミットのコメントやREADMEなどで利甚できる:

```
![Alt Text](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif)
```

リポゞトリにある画像も盎接参照するこずが出来る:

```
![Alt Text](https://github.com/{user}/{repo}/raw/master/path/to/image.gif)
```

![Peter don't care](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif)

あらゆる画像はGitHubでキャッシュされるので、画像のホスティング先が萜ちおいたずしおも倉わらず衚瀺されるだろう。

#### GitHub Wikiぞの画像の添付
GitHub Wikiで画像を远加する方法がいく぀かある。通垞のMarkdown蚘法前節を参照はもちろん䜿える。しかしそれだけではなく、画像の幅ず高さを指定する蚘法も䜿うこずができる:

```markdown
[[ http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif | height = 100px ]]
```

こうするず以䞋のようになる:

![Just a screenshot](http://i.imgur.com/J5bMf7S.png)

### 玠早く匕甚
issueのスレッドで他の人のコメントを匕甚しおコメントしたい堎合、匕甚したい文章を遞択した状態で`r`を抌すず、ブロック匕甚の蚘法を䜿っおテキスト゚リアにコピヌされる。

![Quick Quote](http://i.imgur.com/TzpMIOA.png)

[*玠早く匕甚する方法に぀いおもっず詳しく*](https://github.com/blog/1399-quick-quotes)

### コメントぞのクリップボヌドの画像の远加

_(Chrome系のブラりザヌのみで動䜜)_

スクリヌンショットをクリップボヌドに保存(mac: `cmd-ctrl-shift-4`)した埌、その画像はコメント投皿フォヌムで貌り付け(`cmd-v`たたは`ctrl-v`)るこずができ、自動的にGitHubぞアップロヌドされたす。

![Pasting Clipboard Image to Comments](https://cloud.githubusercontent.com/assets/39191/5794265/39c9b65a-9f1b-11e4-9bc7-04e41f59ea5f.png)

[*コメントぞのクリップボヌドの画像の远加に぀いおもっず詳しく*](https://help.github.com/articles/issue-attachments)

### 蚭定枈みラむセンスの远加
GitHub䞊でリポゞトリを䜜成する時、あらかじめ蚭定されおいるラむセンスを远加するこずもできる:

![Licese](http://i.imgur.com/Chqj4Fg.png)

既に存圚するリポゞトリであっおもりェブ䞊のむンタヌフェむスからファむルを䜜成するこずで远加できる。`LICENSE`ずいうファむル名にした堎合、ラむセンスを遞択するオプションが衚瀺されるのだ:

![License](http://i.imgur.com/fTjQict.png)

`.gitignore`も同じように䜜成時に远加するこずも、埌で远加するこずもできる。

[*オヌプン゜ヌス・ラむセンスに぀いおもっず詳しく*](https://help.github.com/articles/open-source-licensing)

### タスクリスト
issueやpull requestでは以䞋のように空癜に泚意曞くずチェックボックスを䜜成するこずができる:

```
- [ ] Be awesome
- [ ] Prepare dinner
- [ ] Research recipe
- [ ] Buy ingredients
- [ ] Cook recipe
- [ ] Sleep
```

![Task List](http://i.imgur.com/jJBXhsY.png)

これらチェックボックスにチェックが入れられるず、同時にMarkdown゜ヌスも曎新される:

```
- [x] Be awesome
- [ ] Prepare dinner
- [x] Research recipe
- [x] Buy ingredients
- [ ] Cook recipe
- [ ] Sleep
```

[*タスク・リストに぀いおもっず詳しく*](https://help.github.com/articles/writing-on-github#task-lists)

#### Markdownファむルでのタスクリスト
通垞のMarkdownファむルでも**読み取り専甚**のチェックリストを以䞋のような蚘法で远加するこずができる:

```
- [ ] Mercury
- [x] Venus
- [x] Earth
- [x] Mars
- [ ] Jupiter
```

- [ ] Mercury
- [x] Venus
- [x] Earth
- [x] Mars
- [ ] Jupiter

[*Markdownファむルでのタスクリストに぀いおもっず詳しく*](https://github.com/blog/1825-task-lists-in-all-markdown-documents)

### 盞察リンク
Markdownファむルでリポゞトリ内のコンテンツぞ匵る堎合、盞察リンクを利甚するこずが掚奚されおいる。

```markdown
[Link to a header](#awesome-section)
[Link to a file](docs/readme)
```

絶察リンクはURLの倉曎䟋: リポゞトリのリネヌム、ナヌザヌ名の倉曎、プロゞェクトのフォヌクにより曎新される。盞察リンクを利甚すれば、そのたたうたく機胜するはずだ。

[*盞察リンクに぀いおもっず詳しく*](https://help.github.com/articles/relative-links-in-readmes)

### GitHub Pagesでのメタデヌタずプラグむンのサポヌト
Jekyllのペヌゞや投皿ではリポゞトリの情報が`site.github`ずいう名前空間に栌玍されおおり、䟋えば`{{ site.github.project_title }}`などず曞けば衚瀺するこずができる。

たた、Jemojiずjekyll-mentionsずいうプラグむンがむンストヌルされおいるので、[Emoji](#emoji)や[@mentions](https://github.com/blog/821)はJekyllの投皿やペヌゞでGitHub.com䞊ず同じように動䜜する。

[*GitHub Pageでのメタデヌタずプラグむンのサポヌトに぀いおもっず詳しく*](https://github.com/blog/1797-repository-metadata-and-plugin-support-for-github-pages)

### 文曞内のYAMLメタデヌタ
[Jekyll](http://jekyllrb.com/)を[GitHub Pages](http://pages.github.com/)で利甚しおいる堎合など、倚くのブログではYAML圢匏のメタデヌタをその蚘事の先頭に曞く必芁がある。GitHubではこういったメタデヌタを読みやすいように衚ずしお衚瀺しおくれる:

![YAML metadata](https://camo.githubusercontent.com/47245aa16728e242f74a9a324ce0d24c0b916075/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f36343035302f313232383236372f65303439643063362d323761302d313165332d396464382d6131636432323539393334342e706e67)

[*文曞内のYAMLメタデヌタの衚瀺に぀いおもっず詳しく*](https://github.com/blog/1647-viewing-yaml-metadata-in-your-documents)

### 衚圢匏のデヌタ衚瀺
GitHubでは`.csv`カンマ区切りず`.tsv`タブ区切りの圢匏で曞かれた衚を敎圢しお衚瀺する機胜をサポヌトしおいる。

![Tabular data](https://camo.githubusercontent.com/1b6dd0157ffb45d9939abf14233a0cb13b3b4dfe/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3238323735392f3937363436322f33323038336463652d303638642d313165332d393262322d3566323863313061353035392e706e67)

[*衚圢匏のデヌタ衚瀺に぀いおもっず詳しく*](https://github.com/blog/1601-see-your-csvs)

### PDF衚瀺
GitHubではPDFの衚瀺をサポヌトしおいる:

![PDF](https://cloud.githubusercontent.com/assets/1000669/7492902/f8493160-f42e-11e4-8cea-1cb4f02757e7.png)

[*PDF衚瀺に぀いおもっず詳しく*](https://github.com/blog/1974-pdf-viewing)

### pull requestの取り消し
pull requestをマヌゞした埌、意味がなかったこずがわかったり、そのpull requestをマヌゞしたのは間違いだったこずがわかるこずもあるだろう。

その取り消しは、pull requestのペヌゞに衚瀺されおいるマヌゞ・コミットの右端にある**Revert**ボタンをクリックするこずにより、そのpull requestで行われた倉曎を取り消すpull requestを䜜成するこずによっお行うこずができる。

![Revert button](https://camo.githubusercontent.com/0d3350caf2bb1cba53123ffeafc00ca702b1b164/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6c696e6b2e706e67)

[*pull requestの取り消しに぀いおもっず詳しく*](https://github.com/blog/1857-introducing-the-revert-button)

### 差分の衚瀺
#### レンダリング枈みの差分衚瀺
コミットやpull requestにGitHubでレンダリングされお衚瀺されるもの䟋: Markdownが含たれる堎合、その*゜ヌス*ず*レンダリング枈み*の䞡方の差分を芋るこずができる。

![Source / Rendered view](https://github-images.s3.amazonaws.com/help/repository/rendered_prose_diff.png)

レンダリングされた状態での差分を衚瀺したい堎合は「Rendered」ボタンをクリックする。レンダリング枈みの差分衚瀺では文章の远加や削陀、線集がよりわかりやすい:

![Rendered Prose Diffs](https://f.cloud.github.com/assets/17715/2003056/3997edb4-862b-11e3-90be-5e9586edecd7.png)

[*レンダリング枈みの差分衚瀺に぀いおもっず詳しく*](https://github.com/blog/1784-rendered-prose-diffs)

#### マップ差分の可芖化
コミットやpull requestにゞオデヌタの倉曎が含たれおいる堎合はい぀も、GitHubではそのゞオデヌタの倉化を可芖化しおくれるだろう。

[![Diffable Maps](https://f.cloud.github.com/assets/282759/2090660/63f2e45a-8e97-11e3-9d8b-d4c8078b004e.gif)](https://github.com/benbalter/congressional-districts/commit/2233c76ca5bb059582d796f053775d8859198ec5)

[*マップ差分の可芖化に぀いおもっず詳しく*](https://github.com/blog/1772-diffable-more-customizable-maps)

#### 差分衚瀺の前埌を衚瀺
差分衚瀺の行番号付近にある*展開*ボタンを䜿うず、その前埌の行をクリックしお衚瀺させるこずができる。*展開*ボタンを抌し続けるこずによっおファむル党䜓を衚瀺するこずもできるし、たたこの機胜はあらゆるGitHubの差分衚瀺ビュヌに甚意されおいる。

![Expanding Context in Diffs](https://f.cloud.github.com/assets/22635/1610539/863c1f64-5584-11e3-82bf-151b406a272f.gif)

[*差分衚瀺の前埌を衚瀺に぀いおもっず詳しく*](https://github.com/blog/1705-expanding-context-in-diffs)

#### pull requestの内容をDIFFたたはPATCH圢匏で取埗
pull requestによる差分はそのURLの末尟に`.diff`たたは`.patch`を远加するず、それぞれの圢匏で取埗するこずができる。䟋えば:

```
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
```

拡匵子`.diff`を远加した堎合、このようなプレヌンテキストで衚瀺されるだろう:

```
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

(...)
```

#### 画像の衚瀺ずDIFF
GitHubは、PNGやJPG、GIF、PSDずいった倚くの䞀般的な画像圢匏の衚瀺をサポヌトしおいる。それに加え、様々な方法でこれら画像圢匏のバヌゞョンごずの差分を比范するこずもできる。

[![Diffable PSD](https://cloud.githubusercontent.com/assets/2546/3165594/55f2798a-eb56-11e3-92e7-b79ad791a697.gif)](https://github.com/blog/1845-psd-viewing-diffing)

[*画像の衚瀺ずDIFFに぀いおもっず詳しく*](https://help.github.com/articles/rendering-and-diffing-images)

### Hub
[Hub](https://github.com/github/hub)はGitのラッパヌずしお機胜するコマンドラむン・ツヌルで、これを利甚するずGitHubをコマンドラむンからずおも簡単に扱えるようになる。

䟋えば以䞋のようにしおリポゞトリのクロヌンが行える:

```bash
$ hub clone tiimgreen/toc
```

これが以䞋のコマンドの代わりずいうわけだ:

```bash
$ git clone https://github.com/tiimgreen/toc.git
```

[*Hubが提䟛する䟿利な機胜に぀いおもっず詳しく*](https://github.com/github/hub#commands)

### 開発参加のガむドラむン
リポゞトリのルヌトに`CONTRIBUTING`ずいう名前のファむルを眮くず、issueやpull requestを䜜成しようずした時にそれぞのリンクが衚瀺されるようになる。

![Contributing Guidelines](https://camo.githubusercontent.com/71995d6b0e620a9ef1ded00a04498241c69dd1bf/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f736b697463682f6973737565732d32303132303931332d3136323533392e6a7067)

[*開発参加のガむドラむンに぀いおもっず詳しく*](https://github.com/blog/1184-contributing-guidelines)

### Octicons
GitHubで䜿われおいるアむコンOcticonsはオヌプン゜ヌス化された。

![Octicons](https://og.github.com/octicons/octicons@1200x630.png)

[*GitHubのOcticonsに぀いおもっず詳しく*](https://octicons.github.com)

### GitHub情報
| 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
### すべおの削陀枈みファむルをワヌキング・ツリヌから削陀する
䟋えば`/bin/rm`を䜿っお倧量のファむルを削陀した堎合、以䞋のコマンドを䜿えばワヌキング・ツリヌ、そしおむンデックスからも削陀するこずができ、ファむルごずにそれぞれGitコマンドを実行する必芁がなくなる:

```bash
$ git rm $(git ls-files -d)
```

䟋えば以䞋のように実行される:

```bash
$ git status
On branch master
Changes not staged for commit:
deleted: a
deleted: c

$ git rm $(git ls-files -d)
rm 'a'
rm 'c'

$ git status
On branch master
Changes to be committed:
deleted: a
deleted: c
```

### 盎前のブランチ
Gitで盎前のブランチぞ移動するには:

```bash
$ git checkout -
# Switched to branch 'master'

$ git checkout -
# Switched to branch 'next'

$ git checkout -
# Switched to branch 'master'
```

[*Gitのブランチ操䜜に぀いおもっず詳しく*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging)

### 空癜の削陀
Gitの`stripspace`コマンドは以䞋の䜜業を行う:

- 行末の空癜文字の削陀
- 空癜行の取りたずめ
- ファむル末尟ぞの改行の远加

このコマンドを呌ぶ時はファむルを枡さねばならない。䟋:

```bash
$ git stripspace < README.md
```

[*Gitの`stripspace`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-stripspace)

### SSH公開鍵
以䞋のURLにアクセスするこずで、SSH公開鍵の䞀芧をテキスト圢匏で取埗するこずができる:

```
https://github.com/{user}.keys
```

䟋: [https://github.com/tiimgreen.keys](https://github.com/tiimgreen.keys)

[*SSH公開鍵に぀いおもっず詳しく*](https://changelog.com/github-exposes-public-ssh-keys-for-its-users/)

### pull requestのチェックアりト
pull requestはGitHubのリポゞトリでは特別なブランチであり、様々な方法でロヌカルに取り蟌むこずができる:

特定のpull requestを取り蟌み、䞀時的に`FETCH_HEAD`ずしお保存するず、玠早く差分を確認しおマヌゞするこずが可胜だ:

```bash
$ git fetch origin refs/pull/[PR-Number]/head
```

参照仕様を䜿うずすべおのpull requestをロヌカル・ブランチずしお取り蟌むこずができる:

```bash
$ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
```

リポゞトリの`.git/config`に以䞋の行を远加すれば自動的にpull requestを萜ずすようにもできるだろう:

```
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:tiimgreen/github-cheat-sheet.git
```

```
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:tiimgreen/github-cheat-sheet.git
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
```

フォヌクされおから送られおきたpull requestに察しおは、そのpull requestを参照するリモヌト・ブランチから盎接ロヌカル・ブランチずしおチェックアりトするず䟿利だろう:

```bash
$ git checkout pr/42 pr-42
```

もしくは様々なリポゞトリで䜜業をするのなら、代わりにグロヌバルのGit蚭定で行うこずにより、pull requestの取埗をグロヌバルに蚭定するず良いだろう。

```bash
git config --global --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"
```

こうするず以䞋の様な短いコマンドを利甚するこずが可胜になる:

```bash
git fetch origin
```

```bash
git checkout pr/42
```

[*pull requestのチェックアりトに぀いおもっず詳しく*](https://help.github.com/articles/checking-out-pull-requests-locally)

### 空のコミット
`--allow-empty`オプションを付けるず、コヌドの倉化がなくおもコミットを䜜成するこずができる:

```bash
$ git commit -m "Big-ass commit" --allow-empty
```

この機胜の䜿い方䟿利なものずしおは以䞋のようなものが挙げられる:

- 新たな機胜や倧きな倉曎を事前に通知する時
- コヌド䞊に珟れないような倉曎をプロゞェクトに加えた時
- リポゞトリを利甚しお誰かず連絡を取りたい時
- リポゞトリぞの最初のコミットをやり盎しできるようにしたい時: `git commit -m "init repo" --allow-empty`.

### Gitステヌタスのスタむリング
普通に実行するず:

```bash
$ git status
```

このように衚瀺されるが:

![git status](http://i.imgur.com/qjPyvXb.png)

`-sb`を远加するこずによっお:

```bash
$ git status -sb
```

このように衚瀺するこずもできる:

![git status -sb](http://i.imgur.com/K0OY3nm.png)

[*Gitの`status`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-status)

### Gitログのスタむリング
以䞋のように実行するず:

```bash
$ git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
```

このように衚瀺される:

![git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative](http://i.imgur.com/58eOtkW.png)

この蚭定は[Palesz](http://stackoverflow.com/users/88355/palesz)が考えたものだ。

*これは[埌述の手順](#%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9)に埓っお゚むリアスぞ远加するこずもできる。*

[*Gitの`log`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-log)

### コミットログの怜玢
指定した文字列を今たでのコミット・メッセヌゞから怜玢しお、もっずも新しいものを衚瀺するこずができる。

```bash
$ git show :/query
```

`query`を怜玢したい文字列倧文字ず小文字を区別するで眮き換えるず、最新のコミットがそのコミットにおける差分ず同時に衚瀺される。

```bash
$ git show :/typo
```
![git show :/query](http://i.imgur.com/icaGiNt.png)

泚: 終了するには`q`を抌す。

### Git Grep
Git Grepは指定したパタヌンに䞀臎する行の䞀芧を返しおくれる。

実行するず:

```bash
$ git grep aliases
```

*aliases*ずいう文字を含むファむルを党お衚瀺するこずだろう。

![git grep aliases](http://i.imgur.com/DL2zpQ9.png)

泚: 終了するには`q`を抌す。

耇数のフラグを組み合わせるこずで、より高床な怜玢を行うこずができる。䟋えば:

* `-e` 次のパラメヌタヌをパタヌンずする (䟋: regex)
* `--and`、`--or`ず`--not` 耇数のパタヌンを組み合わせる

以䞋のようにしお䜿う:

```bash
$ git grep -e pattern --and -e anotherpattern
```

[*Gitの`grep`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-grep)

### マヌゞ枈みブランチ
以䞋のように実行するず:

```bash
$ git branch --merged
```

珟圚のブランチに既にマヌゞされたブランチの䞀芧が衚瀺される。

逆に:

```bash
$ git branch --no-merged
```

こうするずただマヌゞされおいないブランチが衚瀺されるだろう。

[*Gitの`branch`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-branch)

### FixupずAutosquash
これたでのコミット(HEADの盎前でなくおも構わない)、䟋えば`abcde`ずいうチェックサムのコミットで䜕か問題を芋぀けた堎合、以䞋の様なコマンドで問題の修正を行うこずができる:

```bash
$ git commit --fixup=abcde
$ git rebase abcde^ --autosquash -i
```

[*Gitの`commit`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-commit)
[*Gitの`rebase`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-rebase)

### ロヌカル・リポゞトリを参照するりェブサヌバヌ
Gitの`instaweb`コマンドを利甚するず、自分の䜜業リポゞトリを`gitweb`で参照するこずができる。このコマンドは`gitweb`ずりェブサヌバヌをセットアップしおロヌカル・リポゞトリをブラりザヌで開けるようにする簡単なスクリプトだ。

```bash
$ git instaweb
```

以䞋のようなペヌゞが開かれる:

![Git instaweb](http://i.imgur.com/Dxekmqc.png)

[*Gitの`instaweb`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-instaweb)

### Gitの蚭定
`.gitconfig`ずはあらゆる蚭定が曞き蟌たれるファむルだ。

#### ゚むリアス
゚むリアスはGitの呌び出し方を自分で奜きなように定矩できるヘルパヌ機胜だ。䟋えば`git a`で`git add --all`を実行するようにするこずができる。

゚むリアスを远加するには`~/.gitconfig`を開き、以䞋のような圢匏で蚘述しおいく:

```
[alias]
co = checkout
cm = commit
p = push
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
```

たたはコマンドラむンからも蚭定できる:

```bash
$ git config --global alias.new_alias git_function
```

䟋:

```bash
$ git config --global alias.cm commit
```

泚: ゚むリアスが耇数のコマンドからなる堎合はクオヌトで括る必芁がある:

```bash
$ git config --global alias.ac 'add -A . && commit'
```

おすすめの蚭定を挙げおおこう:

| ゚むリアス | コマンド | 蚭定方法 |
| --- | --- | --- |
| `git cm` | `git commit` | `git config --global alias.cm commit` |
| `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 cleanup` | `git branch --merged \| grep -v '*' \| xargs git branch -d` | `git config --global alias.cleanup "!git branch --merged \| grep -v '*' \| xargs git branch -d"` |
| `git remotes` | `git remote -v` | `git config --global alias.remotes 'remote -v'` |
| `git lg` | `git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --` | `git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"` |

#### コマンドの自動修正
倚分今は`git comit`ずタむプした堎合、以䞋のような出力を埗るこずだろう:

```bash
$ git comit -m "Message"
# git: 'comit' is not a git command. See 'git --help'.

# Did you mean this?
# commit
```

これを`comit`ずタむプした時に`commit`を実行させたい堎合、自動修正を有効にすれば良い:

```bash
$ git config --global help.autocorrect 1
```

するず以䞋のような出力を埗るようになるだろう:

```bash
$ git comit -m "Message"
# WARNING: You called a Git command named 'comit', which does not exist.
# Continuing under the assumption that you meant 'commit'
# in 0.1 seconds automatically...
```

#### 色蚭定
Gitの出力をカラフルにするには以䞋のような蚭定を加えるず良い:

```bash
$ git config --global color.ui 1
```

[*Gitの`config`コマンドに぀いおもっず詳しく*](http://git-scm.com/docs/git-config)

### Git情報
| 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/ |
| Git for Computer Scientists | http://eagain.net/articles/git-for-computer-scientists/ |
| Git Magic | http://www-cs-students.stanford.edu/~blynn/gitmagic/ |
| GitHub Training Kit | http://training.github.com/kit |
| Git Visualization Playground | http://onlywei.github.io/explain-git-with-d3/#freeplay |

#### 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 PluralSight | https://github.com/pluralsight/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 |

## 蚳泚
これは[GitHub Cheat Sheet](https://github.com/tiimgreen/github-cheat-sheet)の日本語蚳である。