Reputation: 1476
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?
Upvotes: 65
Views: 66923
Reputation: 1324258
2017:
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.
This is now customizable, with GitLab 15.6 (November 2022):
Configure default names for branches created from issues
Define a custom template for naming branches created from issues. The previous setting
{issue ID}-{issue-title-hyphenated}
remains the default.To define a custom template for your project, go to
Repository Settings > Branch defaults
.See Documentation and Issue.
Upvotes: 2
Reputation: 1754
TLDR: do a merge request add #2
in the title and/or in the comment box and/or the commit message and it will link the issue to the branch and commit, you could just do a MR right from the start to link it.
It seems the only option for Gitlab is name your branch following this format: <issue-number-some-branch>
like 2-bad-ai
this will autolink the branch to the issue.
However, I organize my branches so they live nicely in the .git/ref/heads folder structure like this feature/2-<some-branch>
then when you do a merge request add #2
in the title and/or in the comment box and/or the commit message and it will link the issue to the branch and commit, you could just do a MR right from the start to link it.
$ ls .git/refs/heads/; ls .git/refs/remotes/upstream/
2-bad-ai dev feature/ hotfix/ master release/
2-bad-ai dev feature/ hotfix/ master release/
I'd much rather have feature/2-bad-ai
in the above output...
From what I can tell on Github you can link pull-request to feature/2-<some-branch>
but doesn't have the autolinking of 2-<some-branch>
like GitLab
Upvotes: 2
Reputation: 713
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.
Upvotes: 54
Reputation: 4665
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
.
Upvotes: 89