Как форкнуть проект на gitlab
Перейти к содержимому

Как форкнуть проект на gitlab

  • автор:

GitLab — Fork a Project

Fork is a duplicate of your original repository in which you can make the changes without affecting the original project.

Forking a Project

Step 1 − To fork a project, click on the Fork button as shown below −

GitLab Fork Project

Step 2 − After forking the project, you need to add the forked project to a fork group by clicking on it −

GitLab Fork Project

Step 3 − Next it will start processing of forking a project for sometime as shown below −

GitLab Fork Project

Step 4 − It will display the success message after completion of forking the project process −

GitLab – Форк Проект

Fork является дубликатом вашего исходного репозитория, в котором вы можете вносить изменения, не затрагивая исходный проект.

Форкинг проекта

Шаг 1 – Чтобы раскрутить проект, нажмите на кнопку Fork , как показано ниже –

GitLab Fork Project

Шаг 2 – После разветвления проекта вам нужно добавить разветвленный проект в группу ветвлений, нажав на него –

GitLab Fork Project

Шаг 3 – Затем он начнет обработку разветвления проекта на некоторое время, как показано ниже –

GitLab Fork Project

Шаг 4 – Он отобразит сообщение об успехе после завершения процесса разработки проекта –

Project forking workflow (FREE)

Whenever possible, it’s recommended to work in a common Git repository and use branching strategies to manage your work. However, if you do not have write access for the repository you want to contribute to, you can create a fork.

A fork is a personal copy of the repository and all its branches, which you create in a namespace of your choice. This way you can make changes in your own fork and submit them through a merge request to the repository you don’t have access to.

Creating a fork

To fork an existing project in GitLab:

On the project’s home page, in the top right, click Fork.

Select the project to fork to:

(Recommended method) Below Select a namespace to fork the project, identify the project you want to fork to, and click Select. Only namespaces you have Developer and higher permissions for are shown.

Choose namespace

NOTE: The project path must be unique in the namespace.

GitLab creates your fork, and redirects you to the project page for your new fork. The permissions you have in the namespace are your permissions in the fork.

WARNING: When a public project with the repository feature set to Members Only is forked, the repository is public in the fork. The owner of the fork must manually change the visibility. Issue #36662 exists for this issue.

Repository mirroring

You can use repository mirroring to keep your fork synced with the original repository. You can also use git remote add upstream to achieve the same result.

The main difference is that with repository mirroring, your remote fork is automatically kept up-to-date.

Without mirroring, to work locally you must use git pull to update your local repository with the upstream project, then push the changes back to your fork to update it.

WARNING: With mirroring, before approving a merge request, you are asked to sync. Because of this, automating it is recommended.

Merging upstream

When you are ready to send your code back to the upstream project, create a merge request. For Source branch, choose your forked project’s branch. For Target branch, choose the original project’s branch.

NOTE: When creating a merge request, if the forked project’s visibility is more restrictive than the parent project (for example the fork is private, the parent is public), the target branch defaults to the forked project’s default branch. This prevents potentially exposing the private code of the forked project.

Selecting branches

Then you can add labels, a milestone, and assign the merge request to someone who can review your changes. Then click Submit merge request to conclude the process. When successfully merged, your changes are added to the repository and branch you’re merging into.

Removing a fork relationship

You can unlink your fork from its upstream project in the advanced settings.

Create a fork with the fork project form (FREE SELF)

  • Introduced in GitLab 13.11.
  • It’s deployed behind a feature flag, disabled by default.
  • It’s disabled on GitLab.com.
  • It’s not recommended for production use.
  • To use it in GitLab self-managed instances, ask a GitLab administrator to enable it. (FREE SELF)

This experimental version of the fork project form is available only if your GitLab administrator has enabled it:

Choose namespace

To use it, follow the instructions at Creating a fork and provide:

  • The project name.
  • The project URL.
  • The project slug.
  • (Optional) The project description.
  • The visibility level for your fork.

Enable or disable the fork project form (FREE SELF)

The new fork project form is under development and not ready for production use. It is deployed behind a feature flag that is disabled by default. GitLab administrators with access to the GitLab Rails console can enable it.

Name already in use

gitlabhq / doc / user / project / repository / forking_workflow.md

  • Go to file T
  • Go to line L
  • Copy path
  • Copy permalink
  • Open with Desktop
  • View raw
  • Copy raw contents Copy raw contents

Copy raw contents

Copy raw contents

Project forking workflow (FREE)

Whenever possible, it’s recommended to work in a common Git repository and use branching strategies to manage your work. However, if you do not have write access for the repository you want to contribute to, you can create a fork.

A fork is a personal copy of the repository and all its branches, which you create in a namespace of your choice. Make changes in your own fork and submit them through a merge request to the repository you don’t have access to.

Creating a fork

    a new form in GitLab 13.11 with a flag named fork_project_form . Disabled by default. in GitLab 14.8. Feature flag fork_project_form removed.

To fork an existing project in GitLab:

  1. On the project’s homepage, in the upper-right corner, select Fork ( ):
  2. Optional. Edit the Project name.
  3. For Project URL, select the namespace your fork should belong to.
  4. Add a Project slug. This value becomes part of the URL to your fork. It must be unique in the namespace.
  5. Optional. Add a Project description.
  6. Select the Visibility level for your fork. For more information about visibility levels, read Project and group visibility.
  7. Select Fork project.

GitLab creates your fork, and redirects you to the new fork’s page.

Update your fork

To copy the latest changes from the upstream repository into your fork, update it from the command line. GitLab Premium and higher tiers can also configure forks as pull mirrors of the upstream repository.

From the command line

To update your fork from the command line, first ensure that you have configured an upstream remote repository for your fork:

Clone your fork locally, if you have not already done so. For more information, see Clone a repository.

View the remotes configured for your fork:

If your fork does not have a remote pointing to the original repository, use one of these examples to configure a remote called upstream :

After ensuring your local copy has the extra remote configured, you are ready to update your fork.

In your local copy, ensure you have checked out the default branch, replacing main with the name of your default branch:

If Git identifies unstaged changes, commit or stash them before continuing.

Fetch the changes to the upstream repository:

Pull the changes into your fork, replacing main with the name of the branch you are updating:

Push the changes to your fork repository on the server (GitLab.com or self-managed):

With repository mirroring (PREMIUM)

A fork can be configured as a mirror of the upstream if all these conditions are met:

  1. Your subscription is (PREMIUM) or a higher tier.
  2. You create all changes in branches (not main ).
  3. You do not work on merge requests for confidential issues, which requires changes to main .

Repository mirroring keeps your fork synced with the original repository. This method updates your fork once per hour, with no manual git pull required. For instructions, read Configure pull mirroring.

WARNING: With mirroring, before approving a merge request, you are asked to sync. You should automate it.

When you are ready to send your code back to the upstream project, create a merge request. For Source branch, choose your forked project’s branch. For Target branch, choose the original project’s branch.

NOTE: When creating a merge request, if the forked project’s visibility is more restrictive than the parent project (for example the fork is private, the parent is public), the target branch defaults to the forked project’s default branch. This prevents potentially exposing the private code of the forked project.

Selecting branches

Then you can add labels, a milestone, and assign the merge request to someone who can review your changes. Then select Submit merge request to conclude the process. When successfully merged, your changes are added to the repository and branch you’re merging into.

Removing a fork relationship

You can unlink your fork from its upstream project in the advanced settings.

  • GitLab blog post: How to keep your fork up to date with its origin.
  • GitLab community forum: Refreshing a fork.

An error occurred while forking the project. Please try again

This error can be due to a mismatch in shared runner settings between the forked project and the new namespace. See Forks in the Runner documentation for more information.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *