Managing Repositories on Git Server Using Gitosis

How to manage users and repositories and how to use these repositories will be introduced in this post. Please refer to Setting Up a Git Server Using Gitosis for how to set up the git server. Please refer to Howto for New Git Users for how to use git as a new user.

Create a new user

Now let’s see how to create a new user user1.

First the new user user1 generates his/her public SSH key and copies or emails the public part of its SSH key to the administrator (we copy to /tmp/user1.pub in this example):

$ ssh-keygen -t rsa
$ cp ~/.ssh/id_rsa.pub /tmp/user1.pub

Then the administrator copies use1‘s public SSH key to the keydir directory in the gitosis-admin repository on the administrator’s local machine:

$ cp /tmp/user1.pub keydir/

Add to the gitosis-admin repository

$ git add keydir/user1.pub

Commit the changes

$ git commit -a -m 'user user1 is added'

Push to the git server

$ git push

After this administrator pushing the new commit, user1 has been added to gitosis on the git server. The name of the user’s public SSH key file is in this format:

user1.pub

Please note that the name of the file should be the same as the user name. For example, the public key file for user1 should be user1.pub .

Create a new repository record in configuration file

All the operations in this part is done by administrator on it’s local machine.

We add a new repository named gitosis-test. In the configuration file, we add a new group gitosis-test-group and we add user1 to it’s members list. This group can write to gitosis-test repository, so that user1 can write to this repository. As described before, add these lines to gitosis.conf file:

[group gitosis-test-group]
writable = gitosis-test
members = user1

We can also grant readonly access to this repository to a group of users as follows:

[group gitosis-test-readonly-group]
readonly = gitosis-test
members = readuser1 readuser2

Then commit and push the changes to the server:

$ git commit -a -m 'config for new repository gitosis-test is added'
$ git push

By now, the new repository record has been added in the configuration file. User user1 is granted write privilege to it. If we want to add another user such as user2 to gitosis-test-group, just make this change:

- members = user1
+ members = user1 user2

Create and use the repository

The user1 can create the repository by itself following the introduction in Howto for New Git Users.

Similar Posts

  • Several Vim Tips (in Chinese)

    窗口模式操作 CTRL-W CTRL-S 将当前窗口分割为两窗口 CTRL-W CTRL-W 切换窗口 CTRL-W j 切换到下一窗口 CTRL-W k 切换到上一窗口 CTRL-W CTRL-R 将窗口的位置轮换 CTRL-W CTRL-_ 将当前窗口最小化 CTRL-W CTRL-= 将所有窗口变为等大 搜索和替换 /word 搜索word 搜索之后按回车高亮显示,n 下一个 p 上一个 :%s/模式/替换成的内容/gc % 全局选项,如果没有开启则只在当前行进行替换 g 表示 全局替换,如果没有g选项则只替换每行出现的第一个单词 c 表示需要确认 Esc替换按键 ESC键在键盘的左上角,按起来很不方便,而在VIM中ESC经常用到,其实有一个同样作用的组合按键:CTRL-[,这两个按起来手基本不用做大的动作,方便多了。 块操作 使用visual可视模式 v 进入可视模式,移动光标可进行选择 CTRL-Q 或 CTRL-V 进入列式模式,可进行块操作,选定的是一个矩形块。如果使用behave mswin CTRL-V可能映射成为past Read more: How to convert between…

  • How to find the history of updated packages by apt-get or aptitude?

    How to find the history of updated packages by apt-get or aptitude? The history is in log files of dpkg and apt: /var/log/dpkg.log /var/log/apt/history.log /var/log/aptitude To check the recently installed packages: cat /var/log/dpkg.log | grep ” install ” To list history of recently installed packages by apt-get: cat /var/log/apt/history.log | grep ” install ” To…

  • Cache at Facebook

    About caching system at Facebook. According to: https://www.facebook.com/notes/facebook-engineering/monitoring-cache-with-claspin/10151076705703920 Facebook has two major cache systems: Memcache, which is a simple lookaside cache with most of its smarts in the client, and TAO, a caching graph database that does its own queries to MySQL. The NSDI’13 paper introduces more about Memcache: https://www.usenix.org/conference/nsdi13/scaling-memcache-facebook The USENIX ATC’13 paper introduces…

Leave a Reply

Your email address will not be published. Required fields are marked *