How can I make a second fork of a GitHub project?

I want to fork a github project to fix a couple of issues and then send a pull request.

The problem I'm running into is that I've already forked the project to adapt it for another user base.

Is it possible to create a second fork? If so, how?

When I try to fork now it just takes me to the previously created fork.


Solution 1:

There is no way to have two forks of the same GitHub project unless you use two different GitHub accounts.

So:

  1. Create a separate GitHub account (and verify the email)

  2. Fork the project

  3. Invite your main GitHub account as a "Collaborator" (from the settings)

You may need to add the extra step of creating an organization with the new GitHub account and inviting your main github account as an owner of the organization (also make sure your new fork is in that new organization). This will let you do things like deploy automatically to a Heroku app that is connected to your main GitHub account.

Why can't we just have multiple forks???

Solution 2:

I mean that I could just commit and push without making a pull request, but I want to do it the offical way and I want somebody else to review the changes before I push to a public project.

GitHub pull requests do not need to be submitted from a fork; they work within a single repository as well:

Pull requests are especially useful in the fork & pull model because they provide a way to notify project maintainers about changes in your fork. However, they're also useful in the shared repository model where they're used to initiate code review and general discussion about a set of changes before being merged into a mainline branch.

There's nothing stopping you from creating a pull request even if you don't technically have to. This is often considered a best practice, and GitHub's own Flow model is largely based on pull requests.

Creating a pull request within a single repository is very similar to creating one from a fork:

  1. Create a feature branch and push your work to that branch on GitHub
  2. In the GitHub web UI, switch to your feature branch
  3. Click the "Compare" & review button

Solution 3:

The best way, recommended by github manual, is use command line git, mirror clone your repo and push it to your github.

https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/duplicating-a-repository

If you strongly prefer GitHub web interface to the command line, a GUI friendly workaround is create a new organization and fork to that new organization.

Another GUI way I can think of is to declare a fork as a template repo using repo's setting so you can crate as many forks as you need.

Solution 4:

The trick is not to use the master branch to create pull requests. Then you won't need to create multiple forks since you can make as many branches as you need and make pull requests against each branch independently.

Given a clean forked repo, create a dedicated branch and use that branch for the pull request.

You can create branches straight from the web UI (although github didn't make it very obvious).

Click the branch selection dropdown, type the new branch name in the input field, and then you'll see a clickable link Create branch: <new-branch-name> as shown below (the tricky UI part is that it might not be very obvious you should click the "create branch" text as there is no actual button as you would probably expect).

github web create branch

In case you already made changes directly in your fork's master branch then consider moving those changes into a dedicated branch and hard resetting the master branch to the original remote so that you keep it clean for synching with the upstream repo.

See also:

  • https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository