跳至主要内容

向仓库添加许可证

您可以在仓库中包含开源许可证,以便让其他人更容易贡献。

本文内容

如果您在仓库中包含可检测的许可证,访问您仓库的用户将在仓库页面顶部看到它。要阅读完整的许可证文件,请点击许可证名称(例如:github-linguist/linguist)。

Screenshot of the main page of a repository. In the right sidebar, "MIT license," preceded by a law icon, is outlined in orange.

开源许可证使他人能够自由使用、修改和分发您仓库中的项目。有关仓库许可证的更多信息,请参阅为仓库授权

在仓库中包含开源许可证

  1. 在 GitHub 上,导航至仓库的主页面。

  2. 在文件列表上方,选择 添加文件下拉菜单,然后点击 创建新文件

    或者,您可以点击在左侧的文件树视图中。

    Screenshot of the main page of a repository highlighting both the "Add file" and the "plus sign" icon, described above, with an orange outline.

  3. 在文件名字段中,键入 LICENSELICENSE.md(全部大写)。

  4. 在文件名下,点击 选择许可证模板

    Screenshot of the new file form, with "LICENSE" entered in the file name field. A "Choose a license template" button is outlined in dark orange.

  5. 在页面左侧的“向项目添加许可证”下,查看可用的许可证,然后从列表中选择一种许可证。

  6. 点击 审阅并提交

  7. 点击 提交更改...

  8. 在“Commit message”字段中,键入简短且有意义的提交信息,描述您对文件所做的更改。您可以在提交信息中将该提交归因于多个作者。欲了解更多信息,请参阅 创建拥有多位作者的提交

  9. 在提交信息字段下方,决定是将提交添加到当前分支还是新分支。如果您当前的分支是默认分支,建议为提交创建一个新分支,然后发起拉取请求。欲了解更多信息,请参阅 创建拉取请求

    Screenshot of a GitHub pull request showing a radio button to commit directly to the main branch or to create a new branch. New branch is selected.

  10. 如果您的 GitHub 账户关联了多个电子邮件地址,请点击电子邮件地址下拉菜单并选择要用作 Git 作者电子邮件地址的邮箱。仅已验证的电子邮件地址会出现在此下拉菜单中。如果您启用了电子邮件地址隐私,则默认的提交作者电子邮件地址将是 “no‑reply”。有关 no‑reply 邮箱的具体形式,请参阅 设置提交电子邮件地址

    Screenshot of a GitHub pull request showing a dropdown menu with options to choose the commit author email address. octocat@github.com is selected.

  11. 点击 提交更改提议更改

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.