Search code examples
gitterminalgitolite

Initialize gitolite repository in existing folder


I'm fairly new to Git and Gitolite, but yesterday I managed to get it up and running.

The thing is, I have a folder with many projects (let's call it /projects) and I'm trying to migrate them to Git. I symlinked Gitolites /repositories folder to this /projects folder, so now every new repo is created in the /projects folder. It works allright.

But now I want to make a repo for every project (subfolder) in the /projects folder. If I initialize a new repo in Gitolite (let's call it /myproject), it creates a new folder called myproject.git instead of using the old myproject folder with the files I'm already working with.

So, how can I turn all the individual projects folders into Git repositories, using Gitolite? I'd like not to manually download and append all those files.


Solution

  • That is the way Gitolite works: it manages bare repositories (the xxx.git folders), not working tree (directories full of files, like projects/myprojects/).

    So: don't symlink repositories to /projects: both are for very different purpose.

    You can inititiate and import each project directly in their own directory (/projects/myproject/.git), and then import it to Gitolite, following "how to configure a migrated git repository in gitolite".


    Pierre De LESPINAY mentions in the comments the official documentation:

    "appendix 1: bringing existing repos into gitolite"

    • Move the repos to $HOME/repositories.
    • Make sure that:
      • They are all bare repos.
      • All the repo names end in ".git".
      • All the files and directories are owned and writable by the gitolite hosting user (especially true if you copied them as root).
    • Run gitolite setup.
      If you forget this step, you can also forget about write access control!

    back on your workstation:

    • If the repos are normal repos, add them to conf/gitolite.conf in your clone of the admin repo, then commit and push the change.
    • If the repos are wildcard repos that already match some repo regex in the conf file, you need to manually create the gl-creator file, like so:
    echo username > ~/repositories/path/to/repo.git/gl-creator