Skip to content
代码片段 群组 项目
未验证 提交 7074a8fe 编辑于 作者: Amy Qualls's avatar Amy Qualls 提交者: GitLab
浏览文件

Begin updating the content of the create-MR page

I'm not the entire way through the page, but I'm losing steam and
we can get value from the updates I've done so far. This commit steps
through the first few subheadings on this page, checking each step
of each process, and updating them to match current expectations.
上级 807a0a54
No related branches found
No related tags found
无相关合并请求
...@@ -22,63 +22,71 @@ You can create a merge request from the list of merge requests. ...@@ -22,63 +22,71 @@ You can create a merge request from the list of merge requests.
1. On the left sidebar, select **Search or go to** and find your project. 1. On the left sidebar, select **Search or go to** and find your project.
1. Select **Code > Merge requests**. 1. Select **Code > Merge requests**.
1. In the upper-right corner, select **New merge request**. 1. In the upper-right corner, select **New merge request**.
1. Select a source and target branch and then **Compare branches and continue**. 1. Select a source and target branch, then select **Compare branches and continue**.
1. Fill out the fields and select **Create merge request**. 1. Complete the fields on the **New merge request** page, then select **Create merge request**.
NOTE: Each branch can be associated with only one open merge request. If a merge request
Merge requests are designed around a one-to-one (1:1) branch relationship. Only one open merge request can already exists for this branch, a link to the existing merge request is shown.
be associated with a given target branch at a time.
## From an issue ## From an issue
> The **Create merge request** button [changed](https://gitlab.com/gitlab-org/gitlab/-/issues/349566) to open the merge request creation form in GitLab 14.8. > [Changed](https://gitlab.com/gitlab-org/gitlab/-/issues/349566) the behavior of the **Create merge request** button to open the merge request creation form in GitLab 14.8.
If your development workflow requires an issue for every merge If your development workflow requires an issue for every merge
request, you can create a branch directly from the issue to speed the process up. request, you can create a branch directly from the issue to speed the process up.
The new branch, and later its merge request, are marked as related to this issue. The new branch, and later its merge request, are marked as related to this issue.
After merging the merge request, the issue is closed automatically, unless After merging the merge request, the issue is closed automatically, unless
[automatic issue closing is disabled](../issues/managing_issues.md#disable-automatic-issue-closing). [automatic issue closing is disabled](../issues/managing_issues.md#disable-automatic-issue-closing):
You can see a **Create merge request** dropdown list below the issue description.
NOTE: ::Tabs
In GitLab 14.8 and later, selecting **Create merge request**
[redirects to the merge request creation form](https://gitlab.com/gitlab-org/gitlab/-/issues/349566)
instead of immediately creating the merge request.
**Create merge request** doesn't display if: :::TabTitle Merge request and branch
- A branch with the same name already exists. To create a branch and a merge request at the same time:
- A merge request already exists for this branch.
- Your project has an active fork relationship.
- Your project is private and the issue is confidential.
To make this button appear, one possible workaround is to 1. On the left sidebar, select **Search or go to** and find your project.
[remove your project's fork relationship](../repository/forking_workflow.md#unlink-a-fork). 1. Select **Issues** and find your issue.
After removal, the fork relationship cannot be restored. This project can no longer 1. Go to the bottom of the issue description.
be able to receive or send merge requests to the source project, or other forks. 1. Select **Create merge request > Create merge request and branch**.
1. In the dialog, review the suggested branch name. It's based on your project's
[branch name template](../repository/branches/index.md) Rename it if the
branch name is already taken, or you need a different branch name.
1. Select a source branch or tag.
1. Select **Create merge request**.
The dropdown list contains the options **Create merge request and branch** and **Create branch**. :::TabTitle Branch only
After selecting one of these options, a new branch or branch and merge request To create only a branch directly from an issue:
is created based on your project's [default branch](../repository/branches/default.md).
The branch name is based on your project's [branch name template](../repository/branches/index.md),
but this value can be changed.
When you select **Create branch** in an empty 1. On the left sidebar, select **Search or go to** and find your project.
repository project, GitLab performs these actions: 1. Select **Plan > Issues** and find your issue.
1. Go to the bottom of the issue description.
1. Select **Create merge request > Create branch**.
1. In the dialog, review the suggested branch name. It's based on your project's
[branch name template](../repository/branches/index.md) Rename it if the
branch name is already taken, or you need a different branch name.
1. Select a source branch or tag.
1. Select **Create branch**.
::EndTabs
If your Git repository is empty, GitLab:
- Creates a default branch. - Creates a default branch.
- Commits a blank `README.md` file to it. - Commits a blank `README.md` file to it.
- Creates and redirects you to a new branch based on the issue title. - Creates and redirects you to a new branch based on the issue title.
- _If your project is [configured with a deployment service](../integrations/index.md) like Kubernetes,_ - If your project is [configured with a deployment service](../integrations/index.md) like Kubernetes,
GitLab prompts you to set up [auto deploy](../../../topics/autodevops/stages.md#auto-deploy) GitLab prompts you to set up [auto deploy](../../../topics/autodevops/stages.md#auto-deploy)
by helping you create a `.gitlab-ci.yml` file. by helping you create a `.gitlab-ci.yml` file.
After the branch is created, you can edit files in the repository to fix If the name of the branch you create is
the issue. When a merge request is created based on the newly-created branch, [prefixed with the issue number](../repository/branches/index.md#prefix-branch-names-with-issue-numbers),
the description field displays the [issue closing pattern](../issues/managing_issues.md#closing-issues-automatically) GitLab cross-links the issue and merge request, and adds the
`Closes #ID`, where `ID` is the ID of the issue. This closes the issue when the [issue closing pattern](../issues/managing_issues.md#closing-issues-automatically)
merge request is merged. to the description of the merge request. In most cases, this looks like `Closes #ID`,
where `ID` is the ID of the issue. If your project is configured with a
[closing pattern](../issues/managing_issues.md#default-closing-pattern), the issue closes
when the merge request merges.
## When you add, edit, or upload a file ## When you add, edit, or upload a file
...@@ -86,10 +94,11 @@ You can create a merge request when you add, edit, or upload a file to a reposit ...@@ -86,10 +94,11 @@ You can create a merge request when you add, edit, or upload a file to a reposit
1. [Add, edit, or upload](../repository/web_editor.md) a file to the repository. 1. [Add, edit, or upload](../repository/web_editor.md) a file to the repository.
1. In the **Commit message**, enter a reason for the commit. 1. In the **Commit message**, enter a reason for the commit.
1. Select the **Target branch** or create a new branch by typing the name (without spaces). 1. Select the **Target branch** or create a new branch by typing the name.
1. Select the **Start a new merge request with these changes** checkbox or toggle. This checkbox or toggle is visible only 1. Select the **Start a new merge request with these changes** checkbox or toggle. This checkbox or toggle is visible only
if the target is not the same as the source branch, or if the source branch is protected. if the target is not the same as the source branch, or if the source branch is protected.
1. Select **Commit changes**. 1. Select **Upload file**.
1. Fill out the fields and select **Create merge request**.
## When you create a branch ## When you create a branch
...@@ -112,20 +121,27 @@ You can create a merge request by running Git commands on your local machine. ...@@ -112,20 +121,27 @@ You can create a merge request by running Git commands on your local machine.
git checkout -b my-new-branch git checkout -b my-new-branch
``` ```
1. Create, edit, or delete files. The stage and commit them: 1. Create, edit, or delete files as needed.
1. Mark the files as ready to commit (staging them) and commit them locally:
```shell ```shell
# Mark the files as ready to commit
git add . git add .
# Commit the changes locally
git commit -m "My commit message" git commit -m "My commit message"
``` ```
1. [Push your branch to GitLab](../../../gitlab-basics/start-using-git.md#send-changes-to-gitlab): 1. [Push your branch and its commits to GitLab](../../../gitlab-basics/start-using-git.md#send-changes-to-gitlab):
```shell ```shell
git push origin my-new-branch git push origin my-new-branch
``` ```
GitLab prompts you with a direct link for creating a merge request: To reduce the number of fields to edit later in the merge request, use
[push options](../push_options.md) to set the value of fields.
1. In the response to the `git push`, GitLab provides a direct link to create the merge request:
```plaintext ```plaintext
... ...
...@@ -135,9 +151,6 @@ You can create a merge request by running Git commands on your local machine. ...@@ -135,9 +151,6 @@ You can create a merge request by running Git commands on your local machine.
1. Copy the link and paste it in your browser. 1. Copy the link and paste it in your browser.
You can add other [flags to commands when pushing through the command line](../push_options.md)
to reduce the need for editing merge requests manually through the UI.
## When you work in a fork ## When you work in a fork
You can create a merge request from your fork to contribute back to the main project. You can create a merge request from your fork to contribute back to the main project.
...@@ -220,3 +233,19 @@ To have merge requests from a fork by default target your own fork ...@@ -220,3 +233,19 @@ To have merge requests from a fork by default target your own fork
1. In the **Target project** section, select the option you want to use for 1. In the **Target project** section, select the option you want to use for
your default target project. your default target project.
1. Select **Save changes**. 1. Select **Save changes**.
## Troubleshooting
### No option to create a merge request on an issue
The option to **Create merge request** doesn't display on an issue if:
- A branch with the same name already exists.
- A merge request already exists for this branch.
- Your project has an active fork relationship.
- Your project is private and the issue is confidential.
To make this button appear, one possible workaround is to
[remove your project's fork relationship](../repository/forking_workflow.md#unlink-a-fork).
After removal, the fork relationship cannot be restored. This project can no longer
be able to receive or send merge requests to the source project, or other forks.
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册