Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default target branch for merges in Gitlab

we are using Gitlab 8.10.1 with many groups and projects. Many of the projects happen to be forks of other projects. Our problem is that whenever somebody opens a merge request for a project the default target branch is NOT the default branch of the project but from one very specific other project. Is there a way to override this setting somehow? Just to make it clear, I know how to set the default branch of a project and those settings appear to be correct, however gitlab doesn't seem to use them when creating merge requests. This issue is very annoying and has led to weird situations when people didn't pay attention and made merge requests with a completely different "master" as target.

like image 727
Tobias Mantsch Avatar asked Aug 12 '16 08:08

Tobias Mantsch


People also ask

How do I change a target branch in merge request?

Go to the pull request and click the ellipsis button and select Edit. From here you can change the target branch for the pr.

What is the default branch in GitLab?

When you create a new project, GitLab sets master as the default branch for your project. You can choose another branch to be your project's default under your project's Settings > General.


1 Answers

The default MR target depends on whether or not the repository is a GitLab fork.

Forks

If the repository is a GitLab fork, then the default MR target will be the default branch of the upstream repository. This relationship can be removed via the "Remove fork relationship" option on the Project settings page, after which the default MR target will be determined as normal for a non-fork repository (described below).

At time of writing, it is not possible to override the default MR target without removing the fork relationship, but that functionality has been requested in gitlab issue #14522.

Non-Forks

If the repository has no fork relationship, then the Default Branch setting on the Project settings page sets both (1) the default MR target, and (2) the HEAD reference of the repo on the GitLab server (which determines the branch that's checked out when the repo is cloned). Note that, due to a bug/quirk in git, problems can occur if a branch that was once the Default Branch is later deleted from GitLab.

At time of writing, it is not possible to change the default MR target independently of the Default Branch, but this functionality has been requested in gitlab issue #17909.

like image 144
David P Avatar answered Oct 11 '22 13:10

David P