Ehsan Korhani Ehsan Korhani - 1 month ago 6x
Git Question

Git: create a new project from an existing one

I am trying to fork an existing project on Github and add some features to the existing code (for my own problem and perhaps unrelated to what the existing code intends to do).

I only need a single JS code from the forked project.

How am I supposed to do that?

How should I change the original author comment (heading) on that JS file?

I want the new comment to reflect that I am the new author, but it has originally created by someone else.


The simplest thing to do, and the one that retains full credit to the original authors and history of the development of your file in context, is to fork the whole project on Github, clone it, delete all the files you don't need, and alter the ones you do. Nothing fancy, just your normal git rm, git add, and git commit. It's good to retain the full history because you and future maintainers can use git blame to discover why some lines are there for future bug hunting.

If the repository is particularly large, you can permanently delete all the other files from history using something like the BFG Repo Cleaner.

You'll also want to check the licensing. It is not legal in most parts of the world to copy and alter someone else's code, even if it's publicly available on Github, unless they grant you that privilege with a license. Check for a LICENSE file for the project, or a license statement within the file. If the project as a whole has a license file, but the individual file does not (very common these days) you probably need to mention that same license in your single file. The details depend on the license.

Note that the original author retains copyright. You are granted license to use and modify their work, if the license grants you that, but they retain copyright.