June 08, 2021

The official way to add a CC license to a GitHub Repository

Creative Commons, License

So I want to add a Creative Common license for a project that I am planning to do. I did some googling and found out that GitHub actually support a few Crative Common licenses, which are listed in their GitHub Docs. The one I need is the cc-by-sa-4.0 license.

However there's an issue. While creating a public repository on the GitHub website, you can choose the license before clicking the Create Repository button. That's what I did, but I couldn't find the cc-by-sa-4.0 license. The only CC license on that list is the cc0-1.0 license. The ["cc", "cc-by-4.0", "cc-by-sa-4.0"] licenses that are listed on the official GitHub documentation are missing from the create new repository page.

Of course I could just get the license from the Creative Commons website or other ways, no biggie, it will still work. The only difference is on the repo's page, if GitHub doesn't recognize the license, it will be a hyperlink with the text View license, and my OCD is going to kill me. I want it show the license name as it is, and it should be supported by GitHub!! So I started digging...


And I found it...

So, GitHub has this website choosealicense.com. I visited many times before to understand the differences between some of the open source licenses. I was on it during the digging just now, and I saw on the bottom right of the page, it has a licenses page link for "Project isn't software". And I found the cc-by-sa-4.0 "hidding" on that page.

If you are like me, want a CC license that's officially supported by GitHub for your repo. You need to be on this site, choosealicense.com. Find the license you need, open the page of that license, and you will see the full license text.

There're two ways to add the license from this website.

  1. Copy the license text, you can do it by either select the text on your own, or click the Copy license text to clipboard button on the top right of the page, and then paste the license text in the LICENSE or LICENSE.txt file of your repository.

  2. You need to create a repository with no license chosen, or you can delete the license from your repository. On the right side of the license page at choosealicense.com, you will see a text input which you can paste the link of your unlicensed GitHub repository, press Enter. Then you will be redirected back to GitHub, click the Review and submit button to continue. The process is very straightforward, commit the license file, create a pull request, merge the pull request. Now the license is added to your GitHub repository.

Now you can see the name of the license is showing exactly as it is on your GitHub repository, not View license.