Git Hosting

From CSCWiki
Revision as of 21:46, 7 December 2021 by R389li (talk | contribs)
Jump to navigation Jump to search

We have a gitea instance running off of caffeine. You can sign in via LDAP to the web interface. Projects used by CSC as a whole are owned by the public organization, except for website-committee related things, which are owned by the www org.


"It's basically GitHub"

- raymo

SSH keys

It is recommended to setup SSH keys so that you do not have to enter your password each time you push to a repo. Once you have uploaded your public key, add the following to your ~/.ssh/config:

        IdentityFile ~/.ssh/id_rsa
        User git

(Replace ~/.ssh/id_rsa by the location of your private SSH key.) Now you should be able to clone, push and pull over SSH.

Continuous Integration

We are running a CI server at It uses OAuth via Gitea for logins, so you need to have logged in to Gitea first. See for documentation. All you have to do is create a .drone.yml file in your repo, then enable CI on the repo from the CSC Drone website. There is an example here.

Pushing and pulling from the filesystem

(for syscom only)
If you need to keep the ability to push/pull from the filesystem, in addition to Gitea, you will need to take the following steps. In this example, we are migrating a repo called 'public/repo.git', which is a folder under /srv/git on caffeine (which is a symlink to /users/git). The way we're doing this right now is kind of hacky, but it works:

  1. Clone the original repo locally: git clone /srv/git/public/repo.git
  2. Delete the old repo (from phosphoric-acid, which has no_root_squash): rm -rf /srv/git/public/repo.git
  3. Create a new repo with the name 'repo' from the Gitea web UI. This should create a bare repository at /srv/git/public/repo.git. (Make sure you choose the 'public' org from the dropdown.)
  4. Push the original repo to the new remote:
    cd repo
    git remote add gitea
    git push gitea master
  5. Remove any git gooks which require gitea:
    rm $(grep -IRl gitea /srv/git/public/repo.git/hooks)
  6. Change file permissions:
    chown -R git:git /srv/git/public/repo.git
    chmod -R g+w /srv/git/public/repo.git

    You will need to do this from phosphoric-acid (due to NFS root squashing).

Note that the repo folder SHOULD be owned by git:git. Anything else will likely break Gitea. (If a user pushes something to the folder and their umask doesn't allow group members to read, for example, then Gitea will be unable to read the repo.)
This means that only trusted users should be in the git group - ideally, only syscom members.