Skip to main content

About forks

A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.

Forking a repository is similar to copying a repository, with two major differences:

  • You can use a pull request to suggest changes from your user-owned fork to the original repository in its GitHub instance, also known as the upstream repository.
  • You can bring changes from the upstream repository to your local fork by synchronizing your fork with the upstream repository.

您可以将仓库复刻到您的个人帐户或具有仓库创建权限的任何组织。 更多信息请参阅“组织中的角色”。

如果您可以访问私有仓库且所有者允许复刻,则您可以将该仓库复刻到您的个人帐户或者 GitHub Team 上您具有仓库创建权限的任何组织。 您不能将私有仓库复刻到使用 GitHub Free 的组织。 更多信息请参阅“GitHub 的产品”。

If you're a member of a 具有托管用户的企业, there are further restrictions on the repositories you can fork. 托管用户 不能复刻企业外部的存储库,也不能复刻内部存储库。 托管用户 可以将企业中组织拥有的私有存储库复刻到企业拥有的其他组织中,或者作为 托管用户 拥有的复刻。 For more information, see "About 企业托管用户."

您可以使用 GitHub Desktop 复刻仓库。 更多信息请参阅“从 GitHub Desktop 克隆和复刻仓库”。

Deleting a fork will not delete the original upstream repository. You can make any changes you want to your fork—add collaborators, rename files, generate GitHub Pages—with no effect on the original. You cannot restore a deleted forked repository. For more information, see "Restoring a deleted repository."

In open source projects, forks are often used to iterate on ideas or changes before they are offered back to the upstream repository. When you make changes in your user-owned fork and open a pull request that compares your work to the upstream repository, you can give anyone with push access to the upstream repository permission to push changes to your pull request branch (including deleting the branch). This speeds up collaboration by allowing repository maintainers the ability to make commits or run tests locally to your pull request branch from a user-owned fork before merging. You cannot give push permissions to a fork owned by an organization.

私有复刻继承上游或父仓库的权限结构。 这有助于私有仓库的所有者保持对其代码的控制。 例如,如果上游仓库是私有的,并授予团队读/写访问权限,则同一团队对该私有上游仓库的任何复刻拥有读/写权限。 私有复刻仅继承团队权限(而不是个人权限)。

If you want to create a new repository from the contents of an existing repository but don't want to merge your changes to the upstream in the future, you can duplicate the repository or, if the repository is a template, you can use the repository as a template. For more information, see "Duplicating a repository" and "Creating a repository from a template".

Further reading