7

I plan to opensource a personal project on github. As a part of this - I plan to add necessary License file(s) in the latest commit prior to making the repository public.

My questions are:

  1. Does the License file(s) have to be in the initial commit, so that all commits/files in the repository adhere to license? --- If that is the case, any recommendation of how to have all the files adhere to the License?

  2. Specifically for the GPL license: Does the license apply for files in older commits, which do not have the GPL copyright header? GPL requires one to add a copyright header in the source code per the guidelines

2
  • 4
    It doesn't really matter when you add the license, as long as you do it before you share your project on Reddit, so that you avoid the embarrassment of having license-bot comment on your post. Apr 23, 2020 at 23:21
  • @curiousdannii What if I had already shared it before I decided to add a license for it?
    – Rainning
    Jan 10, 2023 at 21:50

2 Answers 2

6

It is your own personal project. Thus you have all rights to all content of it and you can license it like you want and when you want. You're in no obligation there at all - unless you make use of libraries or 3rd-party code which requires you to take such action.

There is no explicit requirement on how a license has to look like. It has been common to use a LICENSE file and state the license(s) for the whole repository. You even can list different licenses for different files, if necessary and/or desired (e.g. to distinguish code and art assets or give more detailed attribution).

It is good practise to repeat the license in the header of individual source files. That makes attribution clear when taken out-of-context. Additionally it needs more than an act of copy & paste of a single file to remove the information of its origin, if someone re-uses it somewhere else.

Generally the license is considered to apply to the version of the repository as checked-out. That means a 3rd-party person cannot a priory assume that it applies to revisions of your repository before you commited the license file. However that is not a problem for you. As author you can - in principle - change the license every commit... and of course you can grant people the same rights for older versions (I'd be carful with future ones, though).

3
  • "As author you can - in principle - change the license every commit..." did you mean changing the old commits? But that will change the timestamp of them as well.(If so I would not prefer this way) Is this legally correct to conclude that "after I attach a license to my Repo., all I have done is now being protected"?
    – Rainning
    Jan 10, 2023 at 21:58
  • Oops, I just realized that the answer by @Brandin just clarified my confusion. Still appreciate your answer!
    – Rainning
    Jan 10, 2023 at 22:01
  • 1
    @Rainning At least on GitHub, for the commits that don't have any LICENSE file, even without any specific license declaration, your code is still 'protected' in the sense that someone needs to get your permission to use it. The GitHub TOS by default basically only allow forking and nothing else. So if someone takes your old code commits (sans LICENSE file) and puts that in a product without your permission, for example, that could be a license violation and you could still potentially sue that person if you wish, despite your lack of a "LICENSE" file.
    – Brandin
    Jan 11, 2023 at 5:04
5

The license only applies to the commit on which you committed the license, and any subsequent commits (assuming the subsequent commits do not change the license). For example, let's say you commit code as follows:

  • Commit 1 (January 2019) - Added basic functionality.
  • Commit 2 (February 2019) - Bug fixes.
  • Commit 3 (March 2019) - Added frobulator functionality.
  • Commit 4 (April 2019) - Bug fixes to frobulator functionality.
  • Commit 5 (May 2019) - Added LICENSE stating that all files are under license X.
  • Commit 6 (June 2019) - Edited text for spelling, grammar and punctuation.

In this situation, the license X applies to commit 5, commit 6, and any other subsequent commit which does not change the license. Anyone who got commit 4 or earlier is not allowed to use the software under license X.

In general, if there is no license mentioned, as in the case of commits 1 through 4 in the above fictitious example, then you should refer to What can I assume if a publicly published project has no license?

Specifically for GitHub, however, if a project has no license mentioned, the GitHub terms of service state that if you've posted a project publicly on GitHub, then you are implicitly at least giving permission to users to look at the code and to fork it (i.e. to use the GitHub fork functionality). This would apply specifically to commits 1 through 4 of the above fictitious example.

2
  • Thanks for your answer with examples. Now I finally understand what's going on regarding adding LICENSE. Thank you!
    – Rainning
    Jan 10, 2023 at 22:06
  • Many thanks (again!) for your further explanation below the other answer!
    – Rainning
    Jan 11, 2023 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.