I’ve rarely thought about licensing my code, but it’s something to be aware of for your work. Most of us freely share code, though I have started to add a minor copyright and as is notation to some of my presentation scripts.
Recently a user opened an issue on the SQL Cop repository, noting that without a license, there is some ambiguity for how your code might be used. There’s a short read over at https://choosealicense.com/no-permission/ on this.
I pinged a few people at Redgate to decide what might be best and got pointed to the MIT license, which you can read here: https://choosealicense.com/licenses/mit/#suggest-this-license. After a brief discussion, we decided this would be fine. Actually, people gave me a couple options and said I should pick, so I did.
MIT License it is.
Adding a License
The easy way to do this is to add a file to the repo. If you have this downloaded, just create a new file and commit it. The name should be license.txt (or license). However, you can easily do this online as well.
There is a “Create a new File” in your GitHub repo. Click that.
This gives you an editor, with a name. Enter the filename.
I then pasted in the Mit license into this file. I edited the year and name for Redgate in here as well.
I then committed, this, adding a comment. However there is another way. Once you enter the name license.txt, a button appears on the right side of the page.
This says “Choose a license template”. If you click this, you get a page with other choices.
If you click the “which license” link on the right, you get taken to https://opensource.guide/legal/#which-open-source-license-is-appropriate-for-my-project, where you can read a bit about the differences. If you’re not sure, read this and try to decide what works for you.
In our case, we’re really hosting and sponsoring the project, so the MIT license makes sense. If I go back to the previous page and pick that, I see the license overview and the edits on the right. I changed this from my name to the company, but this defaults to you.
If I click this, I go back to the file page, with the edits filled in. Note the name changes to LICENSE.
I still need to add a commit message and commit this (or create a PR), but this is the meat of the process.
Add a license to your repo to be clear, but make sure it’s the right one for you.