Notes »

Self-hosting git repos

I blogged about it self-hosting git repos.

Adding a new repo

My repos are in /home/reidrac/repos in my server.

How to add a new repo:

  1. Go to the repos directory.

  2. Create a directory:

mkdir my_repo_name
cd my_repo_name
git init --bare
  1. Set the hook for http support:

($PWD is stil “my_repo_name”)

cp hooks/post-update.sample hooks/post-update
  1. Edit decription, set the description.

  2. Optionally, if using cgit, edit config and add:

        owner = My name <my email>

Also the default branch must be “main”, or the “about” section in cgit won’t work (check HEAD).

To get the “idle” column working properly in the index page, add a cgitrc file with your default branch:


(at least cgit v1.2.3 still checks for “master” by default)

  1. On your local copy the repo:
git remote add origin
git push origin main -u

Default branch “main”

If needed, for git 2.28 or later:

git config --global init.defaultBranch main
Last updated Jan 5, 2024