4 KiB
stage | group | info | type |
---|---|---|---|
Create | Source Code | To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments | how-tos |
Develop on a feature branch (FREE)
GitLab values encourage the use of Minimal Viable Change (MVC). However, viable changes are not always small. In such cases, it can help to set up a dedicated feature branch. People can contribute MRs to that feature branch, without affecting the functionality of the default branch.
Once work on the development branch is complete, then the feature branch can be finally merged into the default branch.
GitLab frequently implements this process whenever there is an MVC that requires multiple MRs.
Use case: GitLab release posts
This section describes the use case with GitLab release posts. Dozens of GitLab team members contribute to each monthly release post. In such cases, it may be more efficient to submit an MR on the release post feature branch instead of the default branch.
In this case, the feature branch would be release-X-Y
. Assuming the release-X-Y
branch already exists, you can set up an MR against that branch, with the following steps:
-
Navigate to the default branch (here,
main
):git checkout main
-
Make sure you have the latest version of your repository:
git fetch git pull
-
Check out the feature branch:
git checkout release-x-y
-
Create a new branch (
test-branch
) against the feature branch (release-x-y
):git checkout -b test-branch release-x-y
You should now be on a branch named
test-branch
. -
Make desired changes on the
test-branch
. -
Add your changes, commit, and push to the
test-branch
:git add .
-
Commit your changes:
git commit -m "Some good reason"
-
Push your changes to the repository:
git push --set-upstream origin test-branch
-
Navigate to the URL for your repository. In this case, the repository is
www-gitlab-com
, available athttps://gitlab.com/gitlab-com/www-gitlab-com
.If needed, sign in to GitLab. You should then see an option to Create merge request:
-
After you select Create merge request, an option to Change branches displays. Select that option.
-
In the New merge request screen, you can now select the Source and Target branches. In the screenshot shown, we have selected
test-branch
as the source, andrelease-13-0
as the target. -
Once you've selected the Source and Target branches, select Compare branches and continue. You should see an entry similar to:
New merge request From test-branch into release-13-0
An entry like this confirms your merge request's destination.
-
Make any additional changes in the New merge request screen, and select Create merge request.
-
In the new merge request, look for Request to merge. An entry similar to this displays:
Request to merge test-branch into release-13-0
That confirms you've set up the MR to merge into the specified branch, not the default branch.
-
Proceed with the change as you would with any other MR.
-
When your MR is approved, and an appropriate user merges that MR, you can rest assured that your work is incorporated directly into the feature branch. When the feature branch is ready, it can then be merged into the default branch.