Adding an open-source license to your GitHub project clarifies the terms under which others can use your work. This can clear up potential confusion or avoid legal issues that may arise from infringement of the contract rights.
Learn how to add open-source licenses to your projects hosted on GitHub.
Step 1: Choosing an Open-Source License
Choosing the proper open-source license is important because it will determine how others can interact with and contribute to your open-source project. Many different open-source licenses are available, each with its own terms and conditions.
The MIT License
The MIT License is a popular open-source license that allows others to use, modify, and distribute your work freely, with minimal restrictions. This license does not require users to credit you as the original creator. Instead, it simply requires that users include a copy of the license with any distribution of your project. Projects such as Babel, .NET, Rails, and most npm projects use the MIT License.
The Apache License
The Apache license requires that users credit you as the original creator and include a copy of the license with any distributions. It also allows users to use your work for commercial purposes and does not require them to share modified versions of your work under the same license. Projects such as Kubernetes, PDF.js, and The Swift Programming Language use the Apache license.
The GNU General Public License (GPL)
The GPL is often used for software projects and requires that, if developers distribute a modified version of the software, they do so under the same license. This means that if someone modifies your software and distributes the modified version, they must make the source code for that version available to others under the same terms.
The GPL also requires that users credit you as the original creator of the software and include a copy of the license with any distributions.
There are several different levels of the GNU General Public License (GPL), including the GPLv2, GPLv3, and LGPL (Lesser GNU Public License). Each of these licenses has its own set of terms and conditions, and it is essential to carefully consider which level of the GPL is the best fit for your project. Projects such as Ansible, Bash, and GIMP use the GPL license.
It is important first to determine your project’s goals. Then review the terms and conditions of each license before choosing a license for your project. If you’re still having difficulty choosing a license, the choosealicense.com website can help you make an informed decision about licensing your code.
Step 2: Adding the License to Your Project on GitHub
After choosing an appropriate license, go to your project’s main page on GitHub. Then click the Add file dropdown and select the Create new file option, as shown in the image below.
Next, fill in “LICENSE” or “LICENSE.md” in the file name field and click Choose a license template, as shown in the image below.
Then, review the available licenses available and choose the one best suited for your project, as shown in the image below.
Then, click Review and submit, as shown in the image below.
Finally, write a commit message for your license and choose if you want to commit it directly to the main branch or create a new branch and open a pull request. Then, press the Commit new file button to add the license to your project, as shown in the image below.
If you created a pull request to add the license to your project, merge the pull request, and you should see the LICENSE file on your project’s main page on GitHub.
Tag Releases and Add License Information to Your README Files
You should add your license information to other parts of your projects, such as the release information and your README files.
These additions help to increase visibility and ensure that users are fully aware of the terms and conditions associated with your project.