Change Netlify site repo URL with self-hosted GitLab project

I have set up my Netlify site to be linked to a privately self-hosted GitLab project.

The process I followed was to install the Netlify CLI on my local machine using npm i -g netlify-cli, login into my account with netlify login, run netlify init --manual to get the Netlify SSH key, add it to the Deploy Keys of my privately hosted GitLab instance project, as well as the webhook URL in the Integrations settings page.

I now have to move this project to a new group on GitLab, which changes the URL of the GitLab project.

My question is: How can I change the Site Repo setting of my Netlify site? I cannot figure out how to do this from the Netlify interface, nor from the CLI. I would like to avoid creating a new Netlify site because I have already setup the domain name to link to the existing Netlify site.

Thank you for your help

PS: This is the website:

Hi @nop33! Welcome to netlify community!

You can click Edit settings under Build settings here:

Then you can link to a different repo.

If you want to remove the current repo and not link to a different repo, let us know as that is something we have to do for you.

This is not really the case for self-hosted GitLab repos. When I click the link you suggested, I cannot change the repo. Thanks!

The only available options when clicking “Link to a different repository” are cloud hosted GitHub/GitLab/Bitbucket. No option for self-hosted there.

@nop33, we must manually unlink the repo on our side (Netlify support) currently.

When this is done, you won’t be able to trigger automated build again until you link a new repo to the site. Is it okay for us to do so now (meaning, for us to remove the current repo from the site)?

If the local repo has had the upstream repo URL changed, you can “re-link” using the manual repo link command again (after unlinking it first):

netlify unlink
netlify init --manual

Please let us know here when it is safe for us to unlink the existing repo from the site and we’ll reply again when it is done.

1 Like

Thank you for your help @luke!

Funny thing, after I moved my GitLab repo from path1/repoName to path2/repoName, I noticed that everything still works fine: Opening Merge Requests against deploy branches (as well as pushing to deploy branches) still trigger preview deployments :muscle: . That is probably due to the fact that when the repo was moved, the Webhook URL configuration as well as the Deploy key remained the same.

It seems to me that Netlify doesn’t really check the repo URL. The only minor issue at the moment is what is being displayed in the /settings/deploys page under “Repository” in the Build Settings.

If I confirm to manually unlink the current repo from your side, then I’ll have to re-add the webhook URL and deploy key that I will retrieve from the netlify init --manual process, correct?

Yes, if we do try unlinking and then re-linking the repo, a new webhook URL and deploy key will be generated and these will need to be updated as well.

Thanks for your reply. Since everything works fine at the moment, I’d rather leave it as it is. Thank you for the clarifications!