Renaming a Git repository under Gitolite, keeping an alias for the old name

(If you haven’t yet seen it, Gitolite is a set of scripts for configuring a central Git server – see https://github.com/sitaramc/gitolite)

Renaming a repository is simple and fairly painless:

  1. Log onto your Git server (and any slaves), go to the repositories directory (by default it’s at ~/repositories), and rename your repository:

    mv OldRepoName.git NewRepoName.git

  2. Update your Gitolite configuration to use the new repository name, and push your changes

However, if after renaming the repository you also want to continue supporting the old name (e.g. for a transition period while users move over to the new name), then you can use the alias feature of Gitolite to do that:

  1. Log onto your Git server, and open the “rc” file, which is at ~/.gitolite.rc
  2. Look for the INPUT variable, and add (or uncomment) the line 'Alias::input', inside the array (ensuring it is before the 'Mirroring::input' element), for example:
    INPUT                       =>
            [
                # 'CpuTime::input',
                # 'Shell::input',
                 'Alias::input',
                 'Mirroring::input',
            ],
  3. Add a new variable called REPO_ALIASES with the aliases you want to support:
    REPO_ALIASES    =>
        {
            'foo'   =>  'bar',
        }

Now if you try to interact with the old repository (e.g. git@server:foo) it will redirect to the new repo (git@server:bar), giving the user a warning:

WARNING: 'foo' is an alias for 'bar'