Home > other >  how do i fully migrate my git central repo (--bare)
how do i fully migrate my git central repo (--bare)

Time:06-09

We have setup a central_repo for out team. Everyone from our team will do a git clone from the central_repo and then push back into there.

Now, there is a need for us to move the central_repo to another location due to the fact that we need to save disk space for the current host.

Can I just do this?

git clone --mirror /existing/path/central_repo  /new/path/central_repo
rm -rf /existing/path/central_repo
ln -s /new/path/central_repo /existing/path/central_repo

I did a simple testing myself, and seems like most of the commands are working. However, i just want to make sure that i do not miss out anything and screw up the project and put myself into an irreversible situation if anything happens.

Thank in advance.

CodePudding user response:

It looks like you are trying to move your repository within the same system.

Is that is the case, and if you are in a situation where you can freeze all git actions on your current central repo, e.g:

  • tell colleagues to not run git push until you say so,
  • shutdown your local gitlab instance,
  • suspend your CI jobs ...

you can simply run :

mv /existing/path/central_repo  /new/path/central_repo
ln -s /new/path/central_repo /existing/path/central_repo

note that the git actions you want to prevent are write actions (pushing new commits, updating a branch or a tag). read actions (git clone or git fetch, git ls-remote ...) will not alter the content of your central repository.


The sequence of actions you proposed is ok, there still is the issue of "something was updated between git clone --mirror and rm -rf existing_repo" (note that, unless you have 10k developers who can push at any moment, this issue is actually pretty small in practice).

IMHO you would still need to arrange for a "service down" window (which will be pretty short) to run your migration.

Also to be on the safe side, run :

mv /existing/path/central_repo /existing/path/central_repo_old

#rather than a straight:
rm -rf /existing/path/central_repo

This would at least allow you to inspect the content of central_repo_old before deleting it.

  • Related