Search code examples
gitgitlabgit-repo

How to automatic change git repository domain on the clients when pull?


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.


Solution

  • 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