You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取GitHub组织的仓库默认配置?获取及更新组织默认标签、默认分支的API是否存在?

GitHub组织默认标签、分支及仓库配置API指南

Great question—let's break this down step by step, since I’ve faced similar API gaps while building GitHub Apps for organizational workflows.

1. 组织级默认标签:当前API限制与替代方案

Unfortunately, GitHub doesn’t currently offer a dedicated REST or GraphQL API endpoint to fetch or set organization-wide default tags. Tags remain a repository-level resource, meaning every repo manages its own tag set independently.

That said, you can work around this with a couple of practical approaches:

  • Use a template repository (like the .github repo many organizations use for community health files) as your source of truth for default tags. Define all your organization’s standard tags here, then have your App fetch this repo’s tag list via the repository tags API, and sync those tags to every other repo in the organization.
  • Maintain a centralized list of default tags (stored in something like GitHub Secrets for your organization, or a dedicated config repo). Your App can pull this list on each run, then check each target repo—creating any missing tags automatically.

2. 组织默认分支:可用API端点

Good news here—GitHub does have APIs to manage the default branch name that applies to new repositories in your organization:

  • Fetch the current default branch setting
    GET /orgs/{org}/settings/repository-defaults
    
    This request returns your organization’s repository default config, including the default_branch_name field which holds your organization’s default branch name.
  • Update the default branch setting
    PATCH /orgs/{org}/settings/repository-defaults
    
    Send a JSON body with the new default branch name, like:
    {"default_branch_name": "main"}
    

3. 获取组织仓库默认配置

The same GET /orgs/{org}/settings/repository-defaults endpoint mentioned above is how you retrieve your organization’s full set of repository default settings. It returns a range of defaults that apply when creating new repos, including:

  • Default branch name
  • Whether private repositories are allowed by default
  • Default state for Issues, Projects, and Wiki features
  • Default open source license template
  • Whether head branches are automatically deleted after merging
  • Other repo-creation default behaviors

内容的提问来源于stack exchange,提问作者Sayak Mukhopadhyay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 22:19:04