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. Edit config, add:

[gitweb]
        owner = Juan J. Martinez <my email>

Also:

  • double check default branch is “main”, or the about section won’t work (check HEAD)
  • on the repo:
git remote add origin reidrac@git.usebox.net:/home/reidrac/repos/my_repo_name
git push origin main -u

Default branch “main”

For git 2.28 or later:

git config --global init.defaultBranch main

Or just edit HEAD and s/master/main/.

Last updated Jul 21, 2023