Por Anónimo (no verificado) , 29 Abril 2026

Qué significa "bare"

Un repositorio bare contiene solo los contenidos de .git — sin árbol de trabajo, sin checkout. Es a lo que haces push y de lo que clonas.

Crear uno

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

Push hacia él

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

Compartir en un servidor

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

Clonar

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

SSH vs HTTP

Para equipos pequeños, acceso SSH más git-shell como shell de login del usuario da una configuración limpia y segura.

Herramientas de self-hosting

Para más de un puñado de repositorios, ejecuta Gitea, Forgejo, GitLab Community Edition o similar.

Mirrors y backups

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

Hooks en el lado 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