如何向现有 GitHub 项目添加许可证

How to add license to an existing GitHub project

当我创建一个 GitHub 项目时,我选择了 None。

我现在如何向已添加的项目添加 GPL 许可证?

  1. 转到您的存储库
  2. 点击蓝色加号图标添加新文件
  3. 将文件名键入 License.txt 或 License.md,之后将显示一个许可证选择器。然后你可以选择许可证类型。
  1. 在您的存储库中,单击 'Create new file'


2。 a) 键入 'LICENSE'、'LICENSE.md' 或 'LICENSE.txt' 作为新文件的文件名。 b) 将出现 'Want to use a new template?' 对话框。


  1. 选择您喜欢的许可证。

已接受的答案快到了,但让我感到困惑,因为它说 'click the blue plus' - 界面可能已更改 - 图像与 OP 的相同。

  1. 转到您的存储库
  2. 单击 "Create new file" 按钮
  3. 在存储库名称旁边的输入框中键入文件名 License.txt 或 License.md,右侧会出现一个下拉按钮
  4. 选择您喜欢的许可类型
  5. 单击底部的 "Commit new file" 按钮(绿色按钮)

进入 'Add License' 向导有一种更简单的方法:

  • 转到存储库的 Insights 选项卡
  • 点击左侧的Community
  • 在右侧,单击 License
  • 行上的 Add

出于某种原因,docs at github.

中甚至没有提到这一点

我只是想使用 https://choosealicense.com made by Github and many more 添加另一个有效的替代方法。

ChooseALicense.com aims to provide accurate, non-judgmental, and understandable information about popular open source licenses in order to help people make informed decisions about the projects they start, maintain, contribute to, and use.

选择许可证后,有​​两种替代方法可以转移您的新许可证。

  1. 复制到剪贴板:单击按钮 Copy license text to clipboard 并粘贴到 LICENSE 文件中您想要的任何位置。如何将许可证添加到 Github 已由其他人回答。
  2. Github:填写文本字段 Enter GitHub repository url 并点击 Enter(按下按钮)。您将被要求获得访问您的 Github 存储库的权限。

注意!

Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders

例子