Creating a branch from issue in GitLab
Solution 1
If you create a branch with the name <issue-number>-issue-description
and push that branch to gitlab, it will automatically be linked to that issue. For instance, if you have an issue with id 654
and you create a branch with name 654-some-feature
and push it to gitlab, it will be linked to issue 654
.
Gitlab will even ask you if you want to create a merge request and will automatically add Closes #654
to the merge request description which will close issue 654
when the merge request is accepted.
Also if you go to a given issue page on gitlab, you should see a New Branch
button which will automatically create a branch with a name of the form <issue-number>-issue-description
.
Solution 2
On the Issue screen, you see a green button labeled "Create merge request", with a down-arrow to its right.
That's not a button, that's a drop down list of buttons.
- Click on the down arrow
- Choose "Create branch"
- Click on "Create branch"
- A branch is created from the issue number, plus the title of the branch
- For example, my issue #2, with title "Test repoSearch with no repos" will have a branch called:
- 2-test-reposearch-with-no-repos
- Notice that it changes case to all-lower-case
JonasN89
Updated on July 09, 2022Comments
-
JonasN89 almost 2 years
I've just started using GitLab, and have created a set of issues, in order to keep an overview of what needs to be done for my application. I was wondering if it was possible to create a branch from these issues, such that the branch and issues are linked, similar as in jira and Stash from atlassian?
-
JonasN89 about 7 yearsI was hoping to see a New Branch button, but either its not there or I can't find it. Do you know where it is placed?
-
JonasN89 about 7 yearsnever mind found the create new branch. It seems like Gitlab created a branch for me for the first issue, without realizing it myself.
-
florisla over 6 yearsRegarding the missing Create Branch button, see @Robert Echlin's answer.
-
Zoltán about 6 years@JonasN89 you should consider changing the accepted answer to Robert Echlin's answer because that exactly answers your question.
-
molerat almost 6 yearsThat button is not displayed for me. Does it have to do with my branch structure (Git Flow) or because it is a fork of a different project?
-
Roger Campanera over 5 yearsIs it posible for GitLab to recognise other name format? For instance, create a branch called
feature/2
by default instead of2-the-title
. And, would they be linked by GitLab? That would be a must feature IMHO. -
Michael Kargl almost 5 yearsAn observation: the "Create Pull Request for Issue" Button is only visible once an Issue is Non-Confidential.
-
ThinkDigital over 4 years@molerat I'm having the issue where it's not showing for me either in the current project. In one project, I have 2 buttons. Show Activity and Create Merge Request. In the other, I only have Show Activity
-
fudo almost 4 yearssame here, on some issues the button is displayed while not in others; cannot understand which criteria gitlab uses to show it or not
-
Hendrik Pilz about 3 yearsThe repository must not be empty and the 'repository' feature should be enabled in the project settings (Settings > General > Visibility, project features, permissions). Tested on Gitlab 13.8.7 / Docker.
-
Jubilsoft-Scott over 2 yearsSee this issue regarding the Merge Request button not displaying on the Issue screen.
-
Timothy L.J. Stewart over 2 years@RogerCampanera it seems the only option for Gitlab is
feature/2-<some-branch>
then when you do a merge request add#2
in the comment box and it will link then, you could just do a MR right from the start to link it. From what I can tell on Gitbhub you can link pull-request tofeature/2-<some-branch>
but doesn't have the autolinking of2-<some-branch>
like GitLab