1

I have self-hosted Gitlab installation on a domain. And I need to move Gitlab instance to a different domain. Almost all another Gitlab data will be saved and migrated to a new location.

Is there a solution to automatically and handless change git origin <URL> for any git clients when they perform next pull from the old location? Could be something like server controlled hooks.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Vadim Rybalko
  • 342
  • 2
  • 12

1 Answers1

4

As far I know, you can't from the git server alter the repo url in the "client" side. To do it, you have run some type of script on the "client", but the solution will depend on the OS and the connection type (https ou ssh).

One option is keep the old gitlab online and create a pre-receive hook to deny any push and send back a message like:

   Hey dude! Your project is not here anymore, please access http://newdomain or
   run git `remote set-url http://newdomain/project.git` 

More about gitlab server-side hooks

Joao Vitorino
  • 2,976
  • 3
  • 26
  • 55
  • Is there a way to exec short shell code on the client-side hook with git commands (`git remove origin/git add origin`)? I know that my users have *nix-like OS and uses _git+ssh_ connection. – Vadim Rybalko Aug 04 '20 at 22:13
  • 1
    Yes, there is, YOu don't even need a hook to do it. Create a simple script to run the git commands to change the server / domain and run it on every user machine. But, IMHO, doesn't worth it, recently I passed for the same situation, change gitlab from http to https and is more simple just warn the developers about it and they do the rest of the job. – Joao Vitorino Aug 04 '20 at 22:37