|
| 1 | +--- |
| 2 | +title: "Open Source Licenses" |
| 3 | +sidebar_label: "7. OSS Licenses" |
| 4 | +sidebar_position: 7 |
| 5 | +description: "Understand the legal side of Open Source and learn how to choose the right license for your projects. This is crucial for protecting your work and allowing others to use and contribute to it. Master the art of licensing to ensure your code can be shared and built upon by the community while safeguarding your rights as a creator." |
| 6 | +tags: ["git", "github", "open source licenses", "collaboration", "legal", "protection", "sharing"] |
| 7 | +keywords: ["git", "github", "open source licenses", "collaboration", "legal", "protection", "sharing"] |
| 8 | +--- |
| 9 | + |
| 10 | +Making a repository "Public" on GitHub does not automatically mean people can use, modify, or share your code. Without a **License**, your code is technically under "Exclusive Copyright," meaning you own it and no one else can touch it. |
| 11 | + |
| 12 | +At **CodeHarborHub**, we believe in sharing. A license is a simple text file that tells the community exactly what they are allowed to do with your work. |
| 13 | + |
| 14 | +:::info |
| 15 | +Think of a license like the "Terms and Conditions" for your code. It sets the rules for how others can use, modify, and share your project. Without it, your code is like a locked treasure chest that no one can open. |
| 16 | +::: |
| 17 | + |
| 18 | +## Why Do You Need a License? |
| 19 | + |
| 20 | +1. **Permission:** It legally allows others to "Fork" and "Clone" your project. |
| 21 | +2. **Protection:** Most licenses include a "No Warranty" clause, meaning you aren't responsible if your code breaks someone else's computer. |
| 22 | +3. **Contribution:** Professional developers and companies will *never* use or contribute to a project that doesn't have a clear license. |
| 23 | + |
| 24 | +## The "Big Three" Licenses |
| 25 | + |
| 26 | +There are hundreds of licenses, but in the professional world, 90% of projects use one of these three: |
| 27 | + |
| 28 | +| License | Type | Permission Level | Summary | |
| 29 | +| :--- | :--- | :--- | :--- | |
| 30 | +| **MIT** | **Permissive** | High | "Do whatever you want, just keep my name on it." | |
| 31 | +| **Apache 2.0** | **Permissive** | High | Similar to MIT, but gives extra protection against patent lawsuits. | |
| 32 | +| **GNU GPLv3** | **Copyleft** | Medium | "You can use my code, but your project MUST also be open source." | |
| 33 | + |
| 34 | +## Which One Should You Choose? |
| 35 | + |
| 36 | +### 1. The MIT License (Recommended for Beginners) |
| 37 | +This is the most popular license at **CodeHarborHub**. It is short, simple, and very "friendly." It allows people to use your code in private, commercial, and open-source projects. |
| 38 | +* **Use it if:** You want the most people possible to use your code. |
| 39 | + |
| 40 | +### 2. The Apache License 2.0 |
| 41 | +This is the standard for large-scale professional projects (like Android or Kubernetes). |
| 42 | +* **Use it if:** You are building a serious library or tool and want to be professional about patents. |
| 43 | + |
| 44 | +### 3. The GNU GPLv3 |
| 45 | +This is a "Restrictive" or "Copyleft" license. If someone uses your GPL code, they are legally forced to make their entire project open source too. |
| 46 | +* **Use it if:** You want to ensure that no one ever takes your code and makes a "secret" paid version of it. |
| 47 | + |
| 48 | +## How to Add a License to Your Repo |
| 49 | + |
| 50 | +GitHub makes this incredibly easy. You don't need a lawyer! |
| 51 | + |
| 52 | +1. Go to your repository on GitHub. |
| 53 | +2. Click **Add file** > **Create new file**. |
| 54 | +3. Type `LICENSE` (all caps) as the filename. |
| 55 | +4. A button will appear: **"Choose a license template"**. Click it. |
| 56 | +5. Select a license (like MIT), click **Review and submit**, and commit the file. |
| 57 | + |
| 58 | +## What Happens if I Don't Choose One? |
| 59 | + |
| 60 | +If you have a public repo with **no license**: |
| 61 | +* People can read your code. |
| 62 | +* People can fork your code (because GitHub's Terms of Service allow it). |
| 63 | +* **But**, people cannot legally use your code in their own apps, and they cannot contribute back to you safely. |
| 64 | + |
| 65 | +> **Moral of the story:** If you want people to use your work, always add an **MIT License**. |
| 66 | +
|
| 67 | +:::tip |
| 68 | +Not sure which one fits your specific vibe? Check out [choosealicense.com](https://choosealicense.com/). It's a simple tool created by GitHub to help you pick the perfect legal protection for your code. |
| 69 | +::: |
| 70 | + |
| 71 | +Now that you understand the legal side of sharing your code, you're ready to make your projects truly open source. In the next chapter, we'll dive into how to keep your fork in sync with the original project using the concept of "Upstream." This is essential for contributing to open-source projects and ensuring your code is built on the most recent version of the project. Let's get started!s |
0 commit comments