Publishing code publicly on GitHub does not automatically make it open source.
Without a license, normal copyright law still applies. People can view your repository, and GitHub may allow them to fork it through the platform, but that does not automatically grant permission to reuse, modify, redistribute, or commercially use your code.
An open-source license defines exactly what other developers are allowed to do with your project.
The Main License Families
Open-source licenses can roughly be grouped into three categories:
flowchart LR
A[Permissive] --> B[Weak Copyleft]
B --> C[Strong Copyleft]
A --- A1[MIT / BSD / Apache 2.0]
B --- B1[MPL 2.0 / LGPL]
C --- C1[GPL / AGPL]The major difference is how much openness the license requires from software built using your code.
Permissive Licenses
Permissive licenses place very few restrictions on how software can be reused.
Developers can generally modify your code, redistribute it, use it commercially, and even include it inside proprietary software.
MIT License
The MIT License is one of the simplest and most widely used open-source licenses.
Allows
- Commercial use
- Modification
- Distribution
- Private use
- Proprietary derivatives
Requires
- Preservation of the copyright notice
- Preservation of the MIT license
flowchart TD
A[MIT Licensed Project] --> B[Developer Uses Code]
B --> C[Modify]
B --> D[Commercial Product]
B --> E[Private Project]
C --> F[Keep Copyright + License Notice]
D --> FBest for
Libraries, frameworks, developer tools, SDKs, and projects where maximum adoption is the main goal.
Apache License 2.0
Apache 2.0 provides freedoms similar to MIT but includes more explicit legal protections.
One of its most important features is an explicit patent license from contributors.
Allows
- Commercial use
- Modification
- Distribution
- Private use
- Proprietary derivatives
- Patent use
Requires
- Copyright notices
- License notice
- Documentation of significant modifications
Apache 2.0 also does not automatically grant trademark rights.
Best for
Infrastructure, SDKs, libraries, enterprise software, and larger collaborative projects where patent protection matters.
BSD Licenses
BSD licenses are another family of permissive licenses.
BSD 2-Clause
Requires developers to preserve:
- The copyright notice
- The license and disclaimer
BSD 3-Clause
Adds another restriction: the names of contributors or organizations cannot be used to endorse derived products without permission.
0BSD
The Zero-Clause BSD License removes even the traditional attribution requirement.
Best for
Systems software, libraries, networking tools, and projects that want very few restrictions.
Weak Copyleft Licenses
Weak copyleft licenses try to balance open-source development with proprietary software compatibility.
Instead of requiring an entire application to become open source, they generally apply copyleft requirements only to specific components.
Mozilla Public License 2.0
MPL 2.0 uses file-level copyleft.
If someone modifies an MPL-licensed source file and distributes it, that modified file normally needs to remain available under MPL.
Other files in the same project can remain proprietary.
flowchart TD
A[Application] --> B[MPL File]
A --> C[Proprietary File]
B --> D[Modified MPL File]
D --> E[Must Remain MPL]
C --> F[Can Remain Closed Source]Best for
Projects where you want improvements to your own source files to remain open while still allowing commercial and proprietary integration.
GNU LGPL
The GNU Lesser General Public License is commonly associated with software libraries.
Applications can usually link to an LGPL library without the entire application becoming LGPL.
However, modifications made to the LGPL component itself generally need to remain available under the LGPL when distributed.
flowchart LR
A[Proprietary Application] --> B[LGPL Library]
B --> C[Modified Library]
C --> D[Modified Library Remains LGPL]Best for
Libraries intended to be usable by both proprietary and open-source applications.
Strong Copyleft Licenses
Strong copyleft licenses place stronger requirements on derivative works.
Their purpose is to ensure that software based on open-source code continues providing the same freedoms to future users.
GNU GPL
The GNU General Public License is the most famous strong copyleft license.
You may use, modify, and commercially distribute GPL software.
However, when distributing a derivative work, GPL requirements generally mean that corresponding source code must also be provided under compatible GPL terms.
flowchart TD
A[GPL Project] --> B[Developer Modifies Project]
B --> C{Distributed?}
C -->|No| D[Private Use]
C -->|Yes| E[Provide Corresponding Source]
E --> F[Derivative Remains GPL]Best for
Projects where maintaining long-term software freedom is more important than allowing proprietary derivatives.
GPLv2
GPLv2 is an older but extremely important version of the GPL.
One of the most famous GPLv2 projects is the Linux kernel.
GPLv2 focuses strongly on ensuring that distributed derivative software remains available under GPL-compatible terms.
GPLv3
GPLv3 expanded the GPL model to address newer legal and technological issues.
It includes provisions covering areas such as:
- Software patents
- Anti-circumvention laws
- Certain locked-down hardware
- Installation information
- Contributor patent grants
For many modern projects that want strong copyleft, GPLv3 is the natural choice.
AGPLv3
The GNU Affero General Public License extends the GPL model to software accessed over a network.
This matters particularly for web applications and SaaS platforms.
With normal GPL software, simply running modified software on your own server does not necessarily trigger source-distribution requirements.
AGPL adds a network interaction requirement.
flowchart TD
A[AGPL Project] --> B[Company Modifies Software]
B --> C[Runs Modified Version on Server]
C --> D[Users Access It Over Network]
D --> E[Users Must Be Offered Corresponding Source]Best for
- Web applications
- Server software
- Databases
- Self-hosted platforms
- Backend infrastructure
- SaaS-oriented open-source projects
AGPL is useful when you do not want companies privately modifying your project and offering only a hosted version without sharing those changes.
Public-Domain-Style Licenses
The Unlicense
The Unlicense attempts to release software into the public domain while providing permissive fallback language where direct public-domain dedication is not legally recognized.
It places practically no restrictions on usage.
Allows
- Commercial use
- Modification
- Distribution
- Private use
Best for
Small utilities, examples, snippets, and projects where the author wants essentially unrestricted reuse.
Other Licenses You May Encounter
GitHub repositories can use many other recognized open-source licenses.
For most software projects, however, the practical choice usually comes down to MIT, Apache-2.0, MPL-2.0, LGPL, GPL, or AGPL.
Quick Comparison
* Exact obligations depend on how the software is combined, modified, and distributed.
Which License Should You Choose?
flowchart TD
A[Choose a License] --> B{Want proprietary use allowed?}
B -->|Yes| C{Want explicit patent protection?}
C -->|Yes| D[Apache 2.0]
C -->|No| E[MIT / BSD]
B -->|Partially| F{What should stay open?}
F -->|Modified Files| G[MPL 2.0]
F -->|Library| H[LGPL]
B -->|No / Prefer Copyleft| I{Network services too?}
I -->|No| J[GPL]
I -->|Yes| K[AGPL]In practical terms:
MIT — maximum adoption with very few restrictions.
Apache 2.0 — permissive licensing with stronger patent protections.
MPL 2.0 — keep modifications to individual source files open.
LGPL — keep a library open while allowing proprietary applications to use it.
GPL — require distributed derivative software to remain open.
AGPL — GPL-style copyleft that also covers modified software provided as a network service.
What Happens If You Don't Add a License?
One of the biggest misunderstandings on GitHub is:
Public repository does not mean open-source repository.
Without a license, normal copyright rules apply.
flowchart TD
A[Public GitHub Repository] --> B{LICENSE File?}
B -->|Yes| C[Users Receive License Rights]
B -->|No| D[Default Copyright Applies]
C --> E[Reuse According to License]
D --> F[No Automatic Permission to Reuse or Redistribute]So if you actually want other developers to use your project, adding a license is important.
How GitHub Handles Licenses
A typical repository looks like this:
project/
├── README.md
├── LICENSE
├── src/
└── package.jsonThe license is normally placed in the repository root and commonly named:
LICENSE
LICENSE.md
LICENSE.txtGitHub can automatically detect many well-known licenses and display the detected license directly on the repository page.
The Simplest Way to Remember Everything
There is no universally best open-source license.
The important question is:
What freedoms do you want people to have after they take your code and build something new with it?
If adoption matters most, choose a permissive license such as MIT or Apache 2.0.
If preserving openness matters more, consider MPL, LGPL, GPL, or AGPL depending on how strongly you want that requirement enforced.
Note: This is a developer-oriented explanation of open-source licensing, not legal advice.
