Von Gast (nicht überprüft) , 29 April 2026

Was "bare" bedeutet

Ein Bare-Repository enthalt nur den Inhalt von .git — kein Working Tree, kein Checkout.

Eines erstellen

mkdir myproject.git
cd myproject.git
git init --bare

Dazu pushen

cd ~/work/myproject
git remote add origin /path/to/myproject.git
git push -u origin main

Auf einem Server teilen

scp -r myproject.git user@server:/srv/git/
chgrp -R devs /srv/git/myproject.git
chmod -R g+rwX /srv/git/myproject.git
find /srv/git/myproject.git -type d -exec chmod g+s {} +
# /srv/git/myproject.git/config
[core]
    sharedRepository = group
git init --bare --shared=group myproject.git

Klonen

git clone user@server:/srv/git/myproject.git

SSH versus HTTP

Fur kleine Teams gibt SSH-Zugriff plus git-shell als Login-Shell ein sauberes, sicheres Setup.

Self-Hosting-Tools

Fur mehr als eine Handvoll Repositorys, Gitea, Forgejo, GitLab Community Edition.

Mirror und Backups

git clone --mirror <url> backup.git
cd backup.git
git remote update --prune

Hooks auf der Bare-Seite

# /srv/git/myproject.git/hooks/post-receive
#!/usr/bin/env bash
while read old new ref; do
  if [ "$ref" = "refs/heads/main" ]; then
    cd /srv/www/myproject &&
      git --git-dir=. fetch /srv/git/myproject.git main &&
      git --git-dir=. reset --hard FETCH_HEAD
  fi
done