It used to be possible to create a branch from a gitlab issue, however this functionality is no longer there.
Does it need to be explicitly enabled somewhere?
Or is there a new way to create a branch from an issue?
This one tripped me up as well!
Per the Gitlab user documentation,
https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-new-branch-from-an-issue
The Create merge request button doesn’t display if:
A branch with the same name already exists.
A merge request already exists for this branch.
Your project has an active fork relationship.
To make this button appear, one possible workaround is to remove your
project’s fork relationship. 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.
Otherwise, the button displays as indicated in the post by #Do_Nhu_Vy.
This feature is still exists. Let's see the sceenshot.
Related
I am trying to create a branch linked from an issue on GitLab. The option to create a branch from the issue however is missing on this particular project. I have an access level of Maintainer on this project.
The current project I'm working on:
I have checked the other project I made a few months back on which I have exactly the same access level, the option that I'm looking for is there.
My previous project (This is a different project btw, not the source of the fork)
The difference being is that the current project I am working on is a forked version of the old repo so I could keep historical branches from the previous version of the project. I also imported the issues from the previous repo to the new one. I tried to create a new test issue but I still can't see the menu.
It seems like I configured something wrong, could you please help me identify why I cannot access this menu? Any help would be appreciated.
Thanks!
After some digging, I found that this may be a current known issue on GitLab. It only happens on forked projects similar to #VonC's answer. However it doesn't show how to resolve the issue.
To resolve the issue you have to remove the project's fork relationship found on the Settings > General > Advance. If you forked the repo from another project, you should see the Remove fork relationship button there. This essentially removes the fork relationship of the project from the original repository. Once done, the Create merge request should pop-up immediately upon refreshing the page. Do note you need an Owner access to see the Remove fork relationship option.
For more details, please refer to this issue and this solution was from here.
Check first if this is similar to issue 39778 which refers to issue
I disable the button for projects which are forked.
The context in when it references (from a fork) issue from the original project.
No "Create merge request" in that case.
In git lab, you can create an issue, then within the issue you can create a branch. This branch is linked to the issue (I think because of the issue number at the start of the branch name), such that when you do a merge request on that branch it automatically closes the issue.
So my question is - how can you do this via the API? I can create the issue, but there is no control (as far as I can see) within the issue API to create the related branch.
Is that possible?
It would be nice to be able to create an issue with branch in one go - but I don't think that is possible?
Ok - its not perhaps the best answer, but here is what I came up with for a interim solution (in linux bash):
Raise the issue store response in cmd_resp
Extract the issue ID: echo $cmd_resp | grep -o -P '(?<=iid":).*(?=,"project_id)'.
Where the issue ID is found by looking for: iid":<ISSUE-ID>,"project_id
Create a branch with the name: <ISSUE-ID>-some-branch-name - by having the issue ID at the start of the branch name, gitlab automatically makes a relation to that issue.
So - its quite a simple approach, but it does not feel very integrated. I would still prefer to do that from the point of view of the issue.
It is not possible to create a branch related to an issue via the issues API.
However, this is in line with how RESTful APIs should be designed. If you want to create a branch, you need to make a POST request to the branches API.
POST /projects/:id/repository/branches
As you have already found out, GitLab is quite good at automatically linking issues, MRs and branches together.
For a branch to be linked to an issue, simply start the branch with the issue ID. However, usually it is enough if a merge request is linked to an issue. In my opinion, you shouldn't really be concerned with the branch. You can later access the branch via issue->MR->branch
Merge requests are linked to issues whenever a MR's description text links to an issue (e.g. #1). If you add an issue ID to the Closes statement, the issue will also be closed upon MR resolution.
Therefore, you could simply create a branch via the API, name it however you want. Then, create a MR from that issue and include Closes #1 in your MR description, where 1 is your issue ID.
Further, I would recommend using a more sophisticated REST client. You shouldn't have to parse the issue ID yourself. It is properly set as a field in the JSON response.
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?
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.
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
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
2017:
If you create a branch with the name -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.
Short version: In gitlab how do I view all issues resolved in a commit (or merge request) given that I close issues using git comments (e.g. 'fix #10')?
Long version: In case there is an alternative solution what I'm ultimately trying to accomplish is this. Let's say developer fixes 10 issues, commits, creates merge request and deploys to the staging server. Now QA team needs to know the list of issues that were released so that they can test them. I know this can be done by manually labeling each issue(or assigning a milestone). But since gitlab already knows what issues were resolved in a commit it should be easy to view all issues associated with a commit/merge request. Is it possible to view them?
We are using gitlab to serve our git repositories. Now I've cloned our master project to track my own changes and now I would like to create a merge request to the master again. When I look at the youtube movie, I can see Job selecting a user to assign the merge request to. In my version this whole drop-down box is missing.
Is this because I use version 6.8.2, is it because I do a merge request from a fork? What is happening here?
I would like to be able to select an other team member to review the commit before merging it into the master project.
You're able to assign it to someone on the next screen. We agree that this flow is not ideal so we changed it in 6.9 https://www.gitlab.com/2014/05/22/gitlab-6-9-ee-and-ce-release/