Search code examples
gitrepositorygitolite

How can I host Git repositories and manage my content-hosting myself?


Things such as Github, Bitbucket, DropBox -- manages the content-hosting such as tickets and repo -hosting (DB not tickets but can be used to store repos). I want a solution where I manage myself the content-hosting of thing such as Git -repositories and tickets.

Trial 0: trying to tune Git, too time-consuming

I followed the instructions here but some difficulties then I followed a lot of other tutorials with much more difficulties. I got cloning with "git clone --bare xxx xxx.git; cd xxx; git update-server-info" working but unable to push things with "--shared", got fed up to this kind of manual hacks. There is too much material, too much irrelevant material and too much outdated material.

I repeat I want to do the content-hosting myself. So how can I host my git repos?

Perhaps related

  1. Git repository server I can host locally

  2. Recommendation for code hosting of personal projects


Solution

  • If you're running a Linux server an option is to use Git + SSH.

    On The Server

    1. Create a user account called git which has permissions over your main git project directory. This is useful for allowing all collaborators to push on shared projects.

    2. Add the RSA public key for each of your client machines to the authorized_keys file on the server. (You can generate a private-public key pair using ssh-keygen -t rsa -b 4096 on most Linux distributions.)

    3. Create a new bare repository for your project as the git user. git init myproject --bare

    On the Client

    1. Turn on private key authentication by enabling the IdentifyFile in your ssh_config.

    2. Clone the bare repository. git clone git@<server>:/var/git/myproject

    3. Make your changes.

    4. Commit the changes and push them back to the remote repo. git push origin master

    If you need more specific instructions (such as the exact commands to create a user account) checkout the official Pro Git book.