Skip to main content
REST API теперь версия. Дополнительные сведения см. в разделе "О управлении версиями API".

Конечные точки REST API для Gitignore

Используйте REST API для получения .gitignore шаблонов, которые можно использовать для пропуска файлов и каталогов.

О gitignore

При создании нового репозитория на GitHub.com с помощью API можно указать шаблон .gitignore для применения к репозиторию при создании. С помощью REST API можно получить шаблоны .gitignore из репозитория GitHub Enterprise Cloud .gitignore.

Get all gitignore templates

List all templates available to pass as an option when creating a repository.

Подробные маркеры доступа для "Get all gitignore templates

Эта конечная точка работает со следующими типами маркеров:

Маркер не требует каких-либо разрешений.

Коды состояния http-ответа для "Get all gitignore templates"

Код состоянияОписание
200

OK

304

Not modified

Примеры кода для "Get all gitignore templates"

Пример запроса

get/gitignore/templates
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/gitignore/templates

Response

Status: 200
[ "Actionscript", "Android", "AppceleratorTitanium", "Autotools", "Bancha", "C", "C++" ]

Get a gitignore template

Get the content of a gitignore template.

This endpoint supports the following custom media types. For more information, see "Media types."

  • application/vnd.github.raw+json: Returns the raw .gitignore contents.

Подробные маркеры доступа для "Get a gitignore template

Эта конечная точка работает со следующими типами маркеров:

Маркер не требует каких-либо разрешений.

Параметры для "Get a gitignore template"

Заголовки
Имя., Тип, Description
accept string

Setting to application/vnd.github+json is recommended.

Параметры пути
Имя., Тип, Description
name string Обязательное поле

Коды состояния http-ответа для "Get a gitignore template"

Код состоянияОписание
200

OK

304

Not modified

Примеры кода для "Get a gitignore template"

Пример запроса

get/gitignore/templates/{name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ 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" }