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

  • 3
    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

2 Answers 2


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).


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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