286

Someone gave me access to one of their private repo on Github. What I want to do is to fork that project into my own account, so I could make use of Github's pull request feature.

I only have a basic account on Github, so I cannot make private repos on my own, but if I fork someone else's private repo into my account, is it going to appear in my account as public?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Terence Ponce
  • 9,123
  • 9
  • 31
  • 37

4 Answers4

314

No. You can fork it and it still remains private.

Private collaborators may fork any private repository you’ve added them to without their own paid plan. Their forks do not count against your private repository quota.

https://github.com/plans

funroll
  • 35,925
  • 7
  • 54
  • 59
ebaxt
  • 8,287
  • 1
  • 34
  • 36
  • 3
    Yeah, I've read that. I'm pretty sure this is a stupid question, but could you elaborate more especially on the last sentence? – Terence Ponce Mar 09 '12 at 05:56
  • 3
    It still remains private, just checked myself :) – ebaxt Mar 09 '12 at 05:59
  • 28
    Follow-up question: if you revoke access to the repo on the main account...does it delete your fork? Or at least revoke access to your own fork? – tslater Jan 23 '14 at 05:47
  • http://www.quora.com/GitHub/If-you-fork-a-private-repository-on-GitHub-is-your-fork-made-private-by-default – Bijay Rungta Feb 07 '14 at 15:14
  • 16
    @tslater When you fork a repo you are the owner, and so even if a fork's parent repo is deleted, your fork will remain intact. Furthermore, since you're an admin of the fork, you can still add collaborators (who could also fork), transfer ownership to any user or Organization (orgs can add both admin and read-only users who can ALSO fork), or even just make the repo public. Finally, using these facts to deliberately trick GitHub into giving you "free" private repos is against their TOS and they will probably delete your account if you attempt to do this. – namuol Sep 27 '14 at 04:38
  • 20
    @namuol This has changed as explained in Planet Bips's answer. Now forks are deleted when the main repository is deleted in a private repo. Along with that, forks are deleted if a collaborator loses access to the private repo. https://github.com/blog/2034-greater-control-over-forks-of-your-private-repositories – Matthew D. Scholefield Mar 09 '16 at 16:32
  • thank you ebaxt, I didn't know there is a free student account. – fullmoon Dec 31 '17 at 14:20
37

When you revoke access for a member on the main branch (master repo), it will yank the forked repo as well. So, if you added members to a team, and they forked from the master repo, always ensure that you either have merged their changes or you have a copy of their changes before you remove them from the team, as the members forked repo gets deleted when he is removed from the team and you wont have a way to fetch his changes (if only you care about those).

Planet Bips
  • 471
  • 4
  • 3
  • 1
    Your answer disagrees with the [Github help](https://help.github.com/articles/what-happens-when-i-remove-a-collaborator-from-my-private-repository). I haven't tried it myself. – Don Kirkby Apr 09 '14 at 23:15
  • 4
    There appears to be a difference between removing a team member (https://help.github.com/articles/what-happens-when-i-remove-a-member-from-a-team-in-my-organization) and removing a collaborator (https://help.github.com/articles/what-happens-when-i-remove-a-collaborator-from-my-private-repository). It appears to be the difference between if the private repo is part of an organization (deletes the forks) or not (saves the forks) –  May 18 '14 at 16:43
  • 10
    This is now true: https://github.com/blog/2034-greater-control-over-forks-of-your-private-repositories – VonC Jul 03 '15 at 06:38
12

Real answer.

there are three types of repositories. private, public, and internal. Internal ones require an enterprise account, so we'll forget about them for now. :)

Any fork of one of those retains it's type. Forks of public repositories are public, and forks of private ones are private. Removing access to a private repository deletes that person's fork.

Deleting a private repository deletes all forks of it, which are also private. If you wish to keep a copy, you have to clone and publish it yourself. Which might not be allowed by the code's license. Deleting a PUBLIC repository makes all of the direct forks new masters.

Only the master can be changed from private to public, or vice versa.

Doing either disconnects all forks, and makes them into new masters, all retaining their existing type.

If you wish to delete your private repository while not deleting the other (private) forks, make it public first, which will make all of the private forks into private masters, then delete the repository.

TL:DR; If the repository is public, your fork is public, and stays forever. If the original is private, your fork is private and will vanish if the master does or you do not have access anymore, and you will have to clone and update repeatedly to be sure of keeping it.

This should hopefully answer all questions about forking and deleting. :)

Mr. Beeblebrox
  • 186
  • 1
  • 5
10

Here's GitHub's answer:

https://help.github.com/articles/what-happens-to-forks-when-a-repository-is-deleted-or-changes-visibility/#deleting-a-private-repository

Deleting a private repository

When you delete a private repository, all of its private forks are also deleted.

DeveloperAlex
  • 149
  • 1
  • 4
  • 3
    well, that's stupid. I thought a fork was essentially a hard copy on someone else account. So how do you make it permanent? download it and then re-upload it as a new project? – Jon Grah Mar 25 '19 at 07:35
  • 1
    Yes @Jon Grah, you would download and reupload to hard copy, usually software has a handoff where the original author stops maintaining and gives the blessing to the person forking the project. If that was the case they would archive their project and the fork would persist. Another thing to note, if the repo gets deleted but you have a local copy. Your fork would be deleted on github but you would still be able to create a repo add the remote and push the project up. One of the reasons forking is desirable is because you can update original with fork or fork with original if changes occur. – Michael Dimmitt Feb 02 '21 at 16:24