Git Server aufsetzen

Einen Git-Server aufzusetzen ist sehr einfach. Man sollte sich jedoch rechtzeitig Gedanken machen, ob man repos read-only "servieren" möchte (dafür braucht man im Grunde nämlich gar keinen Git-Server, das geht auch per HTTP), oder ob man read-write access möchte - das ist hier beschrieben.

User git anlegen, in seinem home .ssh anlegen und authorized_keys darin anlegen.

$ sudo chsh -s /bin/git-shell git $ mkdir $HOME/git-shell-commands $ cat >$HOME/git-shell-commands/no-interactive-login <<\EOF #!/bin/sh printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not" printf '%s\n' "provide interactive shell access." exit 128 EOF $ chmod +x $HOME/git-shell-commands/no-interactive-login

Ein Projekt anlegen

Unterhalb des Verzeichnis $GITHOME

$ mkdir project.git && cd project.git && git --bare init

Zum clonen reicht dann:

$ git clone git@gitserver:project.git

Pushen auf mehrere remotes

Empfehlung: ein remote mit namen "all" anlegen:

$ git remote add all git://original/repo.git

Dann remote push URL ändern:

$ git remote set-url --add --push all git://another/repo.git

Dann originale push URL nochmal hinzufügen:

$ git remote set-url --add --push all git://original/repo.git

Überprüfen mit:

$ git remote -v all git://original/repo.git (fetch) all git://another/repo.git (push) all git://original/repo.git (push) <-- ADDED origin git://original/repo.git (fetch) origin git://original/repo.git (push)

Das ginge natürlich auch direkt mit dem origin, aber so kann man jetzt wählen ob man NUR auf origin push't oder auf alle:

$ git push [remote-name] [branch-name] $ git push all master $ git push origin