Gitignore
Gitignore APIは、ファイルやディレクトリを無視するために利用できる.gitignore
テンプレートをフェッチします。
Gitignore APIについて
GitHub.com上に新しいリポジトリをAPIを介して作成する場合、作成時にリポジトリに適用する.gitignoreテンプレートを指定できます。 .gitignore テンプレート API は、GitHub の .gitignore リポジトリからテンプレートを一覧表示してフェッチします。
gitignore のカスタムメディアタイプ
gitignore テンプレートを取得するときに、このカスタムメディアタイプを使用できます。
application/vnd.github.VERSION.raw
詳しい情報については、「メディアタイプ」を参照してください。
Get all gitignore templates
Works with GitHub Apps
List all templates available to pass as an option when creating a repository.
HTTP response status codes
Status code | 説明 |
---|---|
200 | OK |
304 | Not modified |
コードサンプル
get/gitignore/templates
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://api.github.com/gitignore/templates
Response
Status: 200
[
"Actionscript",
"Android",
"AppceleratorTitanium",
"Autotools",
"Bancha",
"C",
"C++"
]
Get a gitignore template
Works with GitHub Apps
The API also allows fetching the source of a single template. Use the raw media type to get the raw contents.
パラメータ
Headers |
---|
名前, 種類, 説明 |
accept stringSetting to |
Path parameters |
名前, 種類, 説明 |
name string必須 |
HTTP response status codes
Status code | 説明 |
---|---|
200 | OK |
304 | Not modified |
コードサンプル
get /gitignore /templates /{name}
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://api.github.com/gitignore/templates/NAME
Response
Status: 200
{
"name": "C",
"source": "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n"
}