Get the App
SLTechnology News&Howtos  ›  Development  › 

How to do fork in gitlab

Shulou Source: shulou.com Published: 2022-06-02 16:24:33 09月24日 Update

This article shows you how to carry out fork in gitlab. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Fork is generally used for open source project collaboration to clone a copy of the original code to your own warehouse through fork and modify it based on your own warehouse; then merge the modified code into the original repository by initiating pull request (also known as merge request).

Fork

Here use gitlab to do the demonstration, first log in to gitlab and find a copy of someone else's project fork.

Then in your own personal project, you can see the code that belongs to your fork.

Keep fork code up to date

After fork completes the code, we will git clone locally to modify the action.

There is a situation here. If the code of the original warehouse is updated and our fork warehouse needs to be obtained, then we need to set the code pull address of the local clone to the original warehouse. First, we look at the original push and pull addresses through the "git remote-v" command.

Git remote-vorigin http://gitlab.xxxx.cn/lu.xu/xxxx-xxxx.git (fetch) origin http://gitlab.xxxx.cn/lu.xu/xxxx-xxxx.git (push)

Then we set the remote address to the original warehouse address.

Git remote set-url origin "original address" # then check out git remote-vorigin http://gitlab.xxxx.cn/xxxx/xxxx-xxxx.git (fetch) origin http://gitlab.xxxx.cn/xxxx/xxxx-xxxx.git (push)

Next, change the address of the local push to the warehouse address of your own fork

Git remote set-url-- push origin "own fork address" # set up and check out git remote-vorigin http://gitlab.xxxx.cn/xxxx/xxxx-xxxx.git (fetch) origin http://gitlab.xxxx.cn/lu.xu/xxxx-xxxx.git (push)

At this point, when we fetch, the code we get is up-to-date, while when we push, push goes to our own fork repository.

Multiple versions use updates

We use fork's warehouse, which is usually based on a feature branch of master checkout.

In the update, we need to cut to master for pull operation to keep the master branch consistent with the original repository.

Then switch to the feature branch and merge the local master so that the feature branch is up to date.

Submit

The submission of the feature branch is submitted directly to its own fork repository.

If you want to merge the feature branch into the original repository, you need to initiate pull request (merge request) in your own fork repository.

The above is how to do fork in gitlab. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Warehouse code address branch project update content skill time knowledge original concise consistent next concise action command foundation that is the situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia Linux vpn Shulou Tech Info