When you are working with GitHub / GitLab public repos, your project is normally an open source project. Meaning: an open source license is applied to the project and available in the repo. Convention is to store the license in a file named LICENSE. Using an OSI approved license 🔗 is common and best practice. Licenses you mostly like find applied at repos are:
- Apache License, Version 2.0 🔗
- Eclipse Public License version 2.0 🔗
- GNU General Public License version 2 🔗
- GNU General Public License version 3 🔗
- ISC License 🔗
- The MIT License 🔗
Speciall the ISC license is popular as it is the standard license for NPM packages (npm init). ISC is similar to the MIT license, but shorter in text. Companies often use Apache 2.0 license as it makes it easier to deal with patents and their IP.
The Apache 2.0 license is rather long 🔗, compared to e.g. ISC or MIT. At the end of the text, there is an appendix.
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.If you wonder what this means: you are not alone. The Apache Foundations offers a FAQ on their license. It contains a question about “How should I apply the Apache License to my own software?” [link 🔗]
“It is also valuable to tag each of your source-code files in case they become detached from the LICENSE file. To apply the Apache License to your source-code files, one approach is to attach the following notice to as a comment at the top of each file.”
Their recommendation is to add the text from the appendix to each of your source code files. The idea behind this is: while having the license at repo / project level is enough, this information is lost when a single source code file is copied or used. In case someone copies some source code files over to another open source project, the information where they come from is lost. Same when scanning individual files for e.g. or license issues.
Therefore, the recommendation (aka valuable) is to add the vital part of license information to each source code file.
Example:
Copyright 2026 Tobias Hofmann
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file [...]As adding the full text given in the appendix might be too much, a shorter version can be used. The short version consists the year, your name and the SPDIX identifier. Two lines with everything a person or a tool needs to know regarding the applied license. Add this as a comment on top of each source code file.
Copyright [yyyy] [name of copyright owner]
SPDX-License-Identifier: Apache-2.0Example:
Copyright 2026 Tobias Hofmann
SPDX-License-Identifier: Apache-2.0Other licenses
Other licenses like MIT or ISC are not explicitely recommending this approach. However, it makes sense. In case you e.g. want to scan a single file for license issues, you do not need to submit the whole repo. The file contains the necessary informatione.
MIT
// Copyright (c) 2026 Tobias Hofmann
// SPDX-License-Identifier: MITISC
// Copyright (c) 2026 Tobias Hofmann
// SPDX-License-Identifier: ISC