Git Server einrichten (Debian)

Aus MattWiki

Anleitung, um einen Git-Server unter Debian 8.0 und Apache 2.2 einzurichten.

Quelle: Pro Git-Handbuch v2 von https://git-scm.com/book/en/v2

Es bestehen mehrere Verfahren, um mit einem Git-Server zu kommunizieren:

  • Lokal Dateizugriff via Filesystem
  • HTTP "dumb" Bis Version 1.6.6 → Zugriff via HTTP/HTTPS nur Read-Only
  • HTTP "smart" Ab Version 1.6.6a
  • SSH
  • Git-Protokoll Ohne Authentifizierung, daher schnell und für große Repositories

Nachfolgende Anleitung bezieht sich auf SSH, und erfordert daher SSH Zugriff.


Installation

# apt-get install git gitweb

Neues leeres Repository auf Server anlegen

Wird mit dem User gemacht, in dessen Zugriffsrechtekontext alles passieren soll.

$ cd ~/
$ mkdir git
$ cd git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in ~/git/project.git/


Repository erstmalig befüllen

Dazu muss ein Repository für das Projekt lokal vorbereitet werden, und auf den Server gepusht werden.

$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/opt/git/project.git
$ git remote -v
$ git push origin master

Repository auf anderen Client runterladen

$ mkdir git
$ cd git
$ git clone git@gitserver:/opt/git/project.git
$ cd project
$ vim README
$ git commit -am 'fix for the README file'
$ git push origin master