GITLAB web IDE change default option - create a new branch - gitlab

I'm using GitLab web IDE, but every time I want to commit my changes the default option is: "Create a new branch", with "Start new merge request" option checked.
I want to push on develop branch, then I switch manually every time to develop... but this boring :(
But before it was automatically "Commit to develop branch".
Is there a solution to restore the previous configuration? thx

When the Web IDE tab is open then the default option for the submit is to create a new branch. But if I choose the other option, then the next commits will keep my selection as the default one.

You can simply set develop as the default branch. The default branch is the branch that changes will automatically be merged into and it's the branch that automatically opens when visiting the GitLab web interface.
These are the steps:
Choose in the leftside menue bar "Settings > Repository > Default Branch"
Determine your default branch

Related

Why do my new branches in Android Studio automatically merge to the previous branches?

I am using the Android Studio functionality to manage my branches/commits etc.
I have the master branch which is reserved for final versions, then I have my development branch and then I open new branches for any features I want to work on.
I've just noticed that my changes in my new branches are automatically merged into my previous branch.
For example, if I'm on the development branch then create a new branch "Image gallery" and add something, when I go back to the development branch, that thing I've added is already there!
This beats the whole purpose of using branches, what is going on? Did I click anything I shouldn't have clicked?
If we are not commit the changes which we are done in the feature branch(image branch), it will added to the development branch when we change the branch local. First we need to commit the changes which is done feature branch(image branch). Then we need to change the branch to the development.

Creating a branch from issue in GitLab

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.

creating a readthedocs.io repo in sync with a public gitlab repo

I have a public gitlab project here
https://gitlab.com/parmentelat/minisim2
I tried to add a corresponding project in readthedocs.io, so that a new commit being pushed onto gitlab triggers a doc rebuild on readthedocs
I do this routinely with projects hosted at github and it's really easy - at least under my setup - since readthedocs shows me an updated list of github repos right away, and everything goes smoothly after that.
When trying to import this gitlab project under readthedocs though, I have to chose 'Import manually' as my gitlab projects would not show up.
(In the 'connected services' of my readthedocs settings page, I could find a way to connect to github and to bitbucket; gitlab does not seem supported)
Fair enough, I try this manual import, but at that point no matter how I try to spell the project's URL and what method (git or https) I try to use for importing the project, I get this error message
This repository doesn't have a valid webhook set up. That means it won't be rebuilt on commits to the repository.
You can resync your webhook to fix this.
is what I am trying to do doable at all ?
do I need to do something specific on the gitlab side
thanks for any hint
You can manually set the webhook on gitlab.com:
Click the settings icon for your project
Select "Integrations"
Enter the above URL, select "Push events" and "Enable SSL verification"
Click "Add Webhook"
That should do it.

Which branch is used when I create a new branch from an issue on Gitlab? Can I choose the source branch?

I'm working on GitLab Community Edition 8.15.3.
When I go to my project --> Issues --> select an issue (let's say which is named "Fix UI problem on IE8") --> New branch.
It creates a new branch named 41-fix-ui-problem-on-ie8 without asking me to select the original/source branch.
My 2 questions are:
What's the default original branch used by Gitlab when I create a new branch from an issue?
Is there a way to "force or activate an option on Gitlab" to give me the choice to select the source branch when I create a new branch from an issue?
When using the "New Branch" button in an issue, the branch is created off of the project's default branch. Normally that would be the master branch, but you can set the project's default branch in the project settings.
UPDATE
GitLab has added the ability to specify the source branch when creating a branch or merge request in an issue. You have to click the dropdown arrow on the "Create merge request" button, and then you'll see these options:
your answers:
What's the default original branch used by Gitlab when I create a new
branch from an issue?
When you create a new branch, by default the current branch you are in is your source branch. you can change it according your requirements.
Is there a way to "force or activate an option on Gitlab" to give me
the choice to select the source branch when I create a new branch from
an issue?
yes you can always change your source branch. if you are creating a new branch github, first select the branch you want to make source, and then create new branch it will show like this:
other wise you can use git command line Interface.. its very powerful then GUI.
see the git command line.
Given the current version of Gitlab, you can now specify the branch source when creating the branch and merge request from an existing issue:

Change Default branch in gitlab

I accidentally pushed my local master to a branch called origin on gitlab and now it is the default. Is there a way to rename this branch or set a new master branch to master?
in the GitLab Enterprise Edition 12.2.0-pre you have to use following:
Setting → Repository → Default Branch ( expand it) and change the default branch Here
In 8.0+ it looks like this was moved into the project. If you open your project and go to the gear icon on the right, then "Edit Project" you can set the default branch for the project.
To change default branch in GitLab:
1. Settings > General > General project settings > Expand
2. Default Branch > Change your project default branch
3. Save changes
For gitlab v10+ (as of Sept 2018), this has moved to settings-> repository -> default branch
As stated by #Luke this is still valid as on 4/1/2021
To change the default branch in Gitlab 7.7.2:
Click Settings in the left-hand bar
Change the Default Branch to the desired branch
Click Save Changes.
In Gitlab version v11.4.4-ee, you can:
Setting
Repository
Default Branch
Settings
General
General Project Settings
In the latest GitLab Community Edition version 9.2.2.:
You have to click on 'Settings' tab located at right most on tabs
panel after opening the project.
Under 'Settings' you will get section 'Default Branch' dropdown
which will give you all branches for the repository. Select the desired branch.
Scroll down to hit green colored 'Save changes' button located just
after 'Project Avatar'.
Please refer image below:
See also GitLab 13.6 (November 2020)
Customize the initial branch name for new projects within a group
When creating a new Git repository, the first branch created is named master by default.
In coordination with the Git project, broader community, and other Git vendors, GitLab has been listening to the development community’s feedback on determining a more descriptive and inclusive name for the default branch, and is now offering users options to change the name of the default branch name for their repositories.
Previously, we shipped the ability to customize the initial branch name at the instance-level and as part of 13.6, GitLab now allows group administrators to configure the default branch name for new repositories created through the GitLab interface.
See Documentation and Issue.
GitLab 13.9 (Feb 2021) details:
Git default branch name change
Every Git repository has an initial branch. It’s the first branch to be created automatically when you create a new repository.
By default, this initial branch is named master.
Git version 2.31.0 (scheduled for release March 15, 2021) will change the default branch name in Git from master to main.
In coordination with the Git project and the broader community, GitLab will be changing the default branch name for new projects on both our SaaS (GitLab.com) and self-managed offerings starting with GitLab 14.0.
This will not affect existing projects.
For more information, see the related epic and the Git mailing list discussion.
Deprecation date: Apr 22, 2021
As promise, with GitLab 13.11 (Apr. 2021):
Git default branch name change
Every Git repository has an initial branch.
It’s the first branch to be created automatically when you create a new repository.
By default, this initial branch is named master.
Future Git versions will change the default branch name in Git from master to main.
In coordination with the Git project and the broader community, GitLab will be changing the default branch name for new projects on both our SaaS (GitLab.com) and self-managed offerings starting with GitLab 14.0.
This will not affect existing projects.
GitLab has already introduced changes that allow users to change the default branch name both at the instance-level (for self-managed users) and at the group-level (for both SaaS and self-managed users).
We encourage users to make use of these features to set default branch names on new projects.
For more information, see the related epic and related blog post.
Settings > Repository > Default Branch
First I needed to remote into my server with ssh. If someone has a non ssh way of doing this please post.
I found my bare repositories at
cd /var/opt/gitlab/git-data/repositories/group-name/project-name.git
used
git branch
to see the wrong active branch
git symbolic-ref HEAD refs/heads/master
to change the master to to be the branch called master then use the web interface and "git branch" to confirm.
In Gitlab CE 9.0, You can change the default branch from the Settings Tab in a repository's header.
For GitLab 11.5.0-ee, go to
https://gitlab.com/<username>/<project name>/settings/repository.
You should see:
Default Branch
Select the branch you want to set as the default for this project. All merge requests and commits will automatically be made against this branch unless you specify a different one.
Click Expand, select a branch, and click Save Changes.
December, 2022
settings >> repository >> Branch defaults :: expand and set your desire branch.

Resources