Da Anonimo (non verificato) , 29 Aprile 2026

Cosa significa "bare"

Un repository bare contiene solo i contenuti di .git — nessun working tree, nessun checkout. E cio a cui si pusha e da cui si clona.

Crearne uno

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

Pushare ad esso

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

Condividere su un server

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

Clonare

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

SSH versus HTTP

Per piccoli team, accesso SSH piu git-shell come login shell dell'utente da un setup pulito e sicuro.

Tool di self-hosting

Per piu di una manciata di repository, eseguire Gitea, Forgejo, GitLab Community Edition.

Mirror e backup

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

Hook sul lato bare

# /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