Personal Git repository

UiOs Git service supports personal Git repositories. Except from registration of the SSH-key one does not need to involve USIT to create new repos. The users are able to adjust the access control and such for their personal Git repositories.

1???Registring the SSH-key

If you're not already a registred Git user your SSH key has to be added to the Git service. This is a manual job that's done by USIT. Send in your public SSH key to unix-drift@usit.uio.no to be registred in the Git service.

2???Create a new repository

All personal Git repos are located at this path:

u/<username>/<repo-name>

To create a repository one only needs to clone the repo (in this example for the user amedov):

$ git clone gitolite@git.uio.no:u/amedov/myrepo
Initialized empty Git repository in /tmp/myrepo/.git/
Initialized empty Git repository in /var/lib/git/repos/u/amedov/myrepo.git/
warning: You appear to have cloned an empty repository.

Then make the content and do a commit:

$ git add *
$ git commit -m 'initial commit'
[master (root-commit) 90de8c8] initial commit
 2 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 bar
 create mode 100644 foo

And then push it upstream:

$ git push origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 262 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: sed: can't read ./description: No such file or directory
To gitolite@git.uio.no:u/trondham/mittrepo
 * [new branch]      master -> master

After this you can use the repo u/amedov/myrepo in ordinary fashion.

3???Commands for the Git service

The Git service supports a few commands that the user can use via SSH against gitolite@git.uio.no:

ssh gitolite@git.uio.no <command> [arguments]

Example:

$ ssh gitolite@git.uio.no help
hello amedov, this is gitolite3 3.3-1.el6 on git 1.7.1

list of remote commands available:

        desc
        help
        info
        perms
        writable

Each of these commands have their own help. Example:

$ ssh gitolite@git.uio.no desc -h
Usage:    ssh git@host desc <repo>
          ssh git@host desc <repo> <description string>

Show or set description for user-created ("wild") repo.

3.1???Change the description of your repo

The description of the personal Git repos are only used for the presentation on the webpage for Git: (http://git.uio.no/). You may change the description yourself. This is done with the command desc. Example:

$ ssh gitolite@git.uio.no desc u/amedov/myrepo 'Amedovs test-repo'

3.2???Access administration

One can add other registred users (see Registring the SSH-key), and the special users "daemon" and "gitweb" to your personal repository with the command perms.

Example: Give access to the users daemon and gitweb, so the repo can be viewable on the web, and for the whole world through the Git protocol:

$ ssh gitolite@git.uio.no perms u/amedov/myrepo + READERS daemon
$ ssh gitolite@git.uio.no perms u/amedov/myrepo + READERS gitweb

Example: Give read and write access to another user:

$ ssh gitolite@git.uio.no perms u/amedov/myrepo + READERS staalej
$ ssh gitolite@git.uio.no perms u/amedov/myrepo + WRITERS staalej

Example: remove the write access:

$ ssh gitolite@git.uio.no perms u/amedov/myrepo - WRITERS staalej

Example: List out users with access:

$ ssh gitolite@git.uio.no perms u/amedov/myrepo -l
READERS daemon
READERS gitweb
READERS staalej
WRITERS staalej

3.3???Close the Git repository

One can temporarily close push to a repository with the command writeable. Example:

$ ssh gitolite@git.uio.no writable u/amedov/myrepo off 'Get off my repolawn!'

If you then try to push to the repo you'll get the message you specified in the former command:

$ git push
FATAL: Get off my repolawn!
fatal: The remote end hung up unexpectedly

To open the repo again, type this:

$ ssh gitolite@git.uio.no writable u/amedov/myrepo on

3.4???List of all your repos

You can get a list of all the repos you have access to with the command info. Example:

$ ssh gitolite@git.uio.no info
hello amedov, this is gitolite@git-prod01 running gitolite3 3.3-1.el6 on git 1.7.1

     C  u/CREATOR/..*
 R W    check_linux_bonding
 R W    check_openmanage
 R W    gitolite-admin
 R W    testing
 R W    u/amedov/myrepo

Please see http://www.uio.no/tjenester/it/maskin/filer/versjonskontroll/git.html for more help

3.5???Delete repo

To delete a repo no longer in use, contact unix-drift@usit.uio.no and ask them to delete your repo.

3.6???External resources

Av Safet Amedov
Publisert 17. sep. 2015 09:48