Tag: license

How to add a license to a repo (and have it be recognized) for an existing GitHub repo – 048

In yesterday’s tip, you saw how to select a license when you create a new project. Today’s tip is about how to get that license picker back for an existing repo.

Since licensing is done based on the content of a file named license in your repo, instead of metadata about the GitHub repository that lives alongside the repo, first, you’ll want to create a new file in your repo.

Create new file button 

Next, type in License and over to the right, the license dropdown button (re)appears. You can call the file license, license.md, LICENSE, or LICENSE.MD, as long as the filename is “license”


When you select a license, for example the MIT License,

Choose a License: MIT License

and you’ll see that the license text is inserted and some boilerplate information, like copyright year and name, are inserted.

MIT license showing copyright year and full username

Now when you commit this file (and wait a minute or so), you’ll see that GitHub now displays the license name at the top of the repo.

MIT license displayed at top of repo above language bar

Suppose you didn’t choose a license via the dropdown picker (either on /new or in the method described above). Suppose you’ve previously pushed a license file up to GitHub at some prior point.

GitHub uses an open source project called Licensee to do license detection, i.e. compare the license file to the list of licenses coming from the Choose a License website. According to the GitHub blog, “Licensee is the same code we use to provide the Licenses API and understand how repositories on GitHub are licensed.”

If you want to contribute to licensee, there’s a contributing guide in the repo. If you’re looking to add a new license that can be detected, you’ll want to check out the choose a license repo.

How to add a license (and choose your own licensing adventure) when you first create a repository on GitHub – 047

For the longest time, I thought it was required that you select a README in order to select a license. Although you should have both (ideally) in your repo, you don’t have to create a readme file on the /new page just to set a license file.

In the image below, the Initialize this repository with a README is unchecked, while the MIT License is being selected for the Add a license dropdown button.

adding MIT License without the Initialize this repo with a README checked

Remember, just like a readme, the license for your GitHub repo is only a file that’s within the repo itself (and doesn’t automatically get added to a Visual Studio solution – something that took me a long time to wrap my head around).

LICENSE file shown in repo file listing

But suppose you know you need a license, but want to go over what your options are. There’s a (?) button right next to the Add a license dropdown button on the /new page.

choose a license help icon

Clicking on this help icon button will take you the Choose a License website, a “choose your own adventure”-style site where you can learn more about licensing!

Got a suggestion for the Choose a License website? The website (a github pages site) is an open source project accepting contributions!

Down in the bottom right corner of the footer, you see a link to the repo

Curated with <3 by GitHub, Inc. and You!

I call out this link because adding the “and You!” link was my first ever Pull Request. These Pull Request-related tips won’t really click until you’ve walked through submitting a Pull Request yourself. I hope by sharing my lightbulb experiences from my first few PRs that it will help others get a sense of what the process is like.