惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
T
The Blog of Author Tim Ferriss
IT之家
IT之家
罗磊的独立博客
博客园_首页
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
博客园 - 叶小钗
H
Help Net Security
N
Netflix TechBlog - Medium
B
Blog
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
V2EX
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)

Emil Burzo

GPS spoofing teleported me to Peru, mid-flight Running Claude Code dangerously (safely) Reverse engineering the Nest home/away API Tracking down an old OkHttp regression What does StackOverflow's personalized prediction data think of you? Cum se plătesc impozitele PFA prin BT24 Work-around for when keyserver.ubuntu.com is down Creating a tailable cursor on MongoDB 3 with the Java driver API Quick fix for CVE-2015-1328 Analiza parcului auto din România
Setting up gitolite on Ubuntu 12.04 LTS
2014-02-19 · via Emil Burzo

Introduction

In this post we will be looking at how to self-host git using gitolite.

First off, you will have to decide if you are ok with using the (slightly older) version in the Ubuntu package repository.

Right now, gitolite is at version 3, while the version in the LTS repository is 2.

Moving on, in this guide we will be using the repository version.

Setup

Use apt-get to install gitolite

sudo apt-get install gitolite

After that’s done, we proceed with configuring gitolite:

sudo dpkg-reconfigure gitolite

You will be presented with some pretty dialog… dialogs with the following questions:

System username for gitolite

You can leave the default gitolite username, but if you want to type less when cloning git repositories, you can set it to git (don’t forget to check if the username not already taken by something else on the system)

Repository path

If you are unsure, you can leave the default.

Personally, I prefer /home/gitolite

Administrator’s SSH key

You can either upload your public key file (you do have one, right? if not, see here) somewhere on the server and input the path to the file, or paste it directly.

The administrative repository

Gitolite operates under the principle that you have an administrative repository, and you configure everything from there.

Therefore, we clone the administrative repository:

git clone GITOLITE_USERNAME@SERVER_ADDRESS:gitolite-admin.git

For example:

git clone git@192.168.0.146:gitolite-admin.git

This URI scheme assumes you are using the standard SSH port (22).

If that is not the case, you will have to use the following, lengthier syntax:

git clone ssh://GITOLITE_USERNAME@SERVER_ADDRESS:SERVER_PORT/gitolite-admin.git

Example:

git clone ssh://git@192.168.0.146:12345/gitolite-admin.git

By default, the gitolite administrative repository looks like this:

gitolite-admin/
|-- conf                      <-- configuration dir
|   `-- gitolite.conf         <-- configuration file
`-- keydir                    <-- key store directory
    `-- admin.pub             <-- key file, must end in .pub

Creating a new repository

We edit the gitolite-admin/conf/gitolite.conf file and add the following:

repo    REPOSITORY_NAME
        RW+     =   USER_KEY_NAME

For example:

repo    testing
        RW+     =   admin

The permission types are:

  • R means “read” permission
  • RW means “read and write”, but no rewind
  • RW+ means “read and write”, with rewind allowed

Save the config file then commit the changes:

git add .
git commit -m "created testing repository"
git push

Git documentation is outside the scope of the tutorial.

Congratulations! You now have a new repository which you can clone like so:

git clone git@192.168.0.146:testing.git

And that’s it!

But what if we want to give someone else access to our repository?

Adding a new user

First, you need to add his or hers ssh public key to the keydir folder in a file with the following name: user.pub

After that, we edit the gitolite.conf file and add the user to the appropriate directory.

From the gitolite-admin folder, we save and push everything:

git add -A .
git commit -m "added user XXX"
git push

And that should be it.

Tips

  • A user can have multiple key files, just add more files and keep this naming pattern: user@host.pub, user@another-host.pub, user@whatever.pub. And in the config file you can just reference ‘user’ and it will work with any of the previous three keys.
  • Use an openssh ssh_config file to simplify git URIs or ssh connections