when opening a project in gitlab, you will see SSH and HTTP(or HTTPS) url on the top of project home page, the SSH url is as default, but I want to set HTTP(or HTTPS) as default, so how should I do? Thanks
How can I change the URL on gitlab.com? Hey @simonmeusel, you can change the URL of a project by navigating to Settings -> General -> Advanced within the project and changing it in the Rename repository section. Just keep in mind you'll need to update that repository locally with the new location once you've done so.
Your project's URL is https://gitlab.com/websites/websites.gitlab.io . Once you enable GitLab Pages for your project, your website is published under https://websites.gitlab.io . General example: On GitLab.com, a project site is always available under https://namespace.gitlab.io/project-name.
Use the project general settings to edit your project details. Sign in to GitLab with at least the Maintainer role. On the top bar, select Menu > Projects and find your project. On the left sidebar, select Settings > General.
If you're a GitLab.com user, the base URL is https://gitlab.com .
infact, you have to modify 2 other lines above the default_clone_protocol.
def default_url_to_repo(project = nil)
project = project || @project
current_user ? project.http_url_to_repo : project.url_to_repo
end
def default_clone_protocol
current_user ? "http" : "ssh"
end
The app/views/shared/_clone_panel.html.haml
file does show:
.git-clone-holder.input-group
.input-group-btn
%button{class: "btn #{ 'active' if default_clone_protocol == 'ssh' }", :"data-clone" => project.ssh_url_to_repo} SSH
%button{class: "btn #{ 'active' if default_clone_protocol == 'http' }", :"data-clone" => project.http_url_to_repo}= gitlab_config.protocol.upcase
And that default_clone_protocol is defined in app/helpers/projects_helper.rb
def default_clone_protocol
current_user ? "ssh" : "http"
end
So you could change that code, or add a setting in config/gitlab.yml.example
in order to make it a parameter.
As mentioned by Mosi Wang's answer, the function default_url_to_repo
also plays a role in the definition of that order, since it returns project.url_to_repo : project.http_url_to_repo
.
Reversing the order can help too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With