Git Server (Linux): Unterschied zwischen den Versionen

Aus Tutorials
Zur Navigation springen Zur Suche springen
 
(25 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:




[[Datei:GitPushForceYoda.jpg]]
[[Datei:GitPushForceYoda.jpg|323px]] [[Datei:Git-push-force.png]]
 


== Installation ==
== Installation ==
Zeile 125: Zeile 126:
[https://git-scm.com/book/de/v1/Git-auf-dem-Server-Git-Daemon https://git-scm.com/book/de/v1/Git-auf-dem-Server-Git-Daemon]
[https://git-scm.com/book/de/v1/Git-auf-dem-Server-Git-Daemon https://git-scm.com/book/de/v1/Git-auf-dem-Server-Git-Daemon]


=== GitWeb und HTTP-Zugriff ===
=== Webinterface ===


<pre>
[[GitWeb (Ubuntu)|GitWeb]]
git clone git://git.kernel.org/pub/scm/git/git.git
cd git
make GITWEB_PROJECTROOT="/home/git" prefix=/usr gitweb
sudo cp -Rf gitweb /var/www/
sudo chown -R www-data:www-data /var/www/gitweb
</pre>


Bzw. über
[[GitLab (Ubuntu)|GitLab]]
<pre>
sudo apt-get install gitweb
</pre>


==== Apache ====
== Repository anlegen ==


<pre>
<pre>
sudo -u www-data htdigest -c /home/git/.htpasswd "Shared Git Repo" martin
cd /home/git
</pre>
mkdir project.git
 
cd project.git
<pre>
git --bare init
cd /etc/apache2/sites-available/
</pre>
 
===== http =====
 
<pre>
sudo vi gitweb.conf
</pre>
 
<pre>
<virtualhost *:80>
    ServerName git.<domain>
    DocumentRoot /var/www/gitweb
 
    <Directory /var/www/gitweb>
        Options +FollowSymLinks +ExecCGI
        AddHandler cgi-script .cgi
        DirectoryIndex gitweb.cgi
    </Directory>
 
    ScriptAliasMatch \
        "(?x)^/(.*/(HEAD | \
        info/refs | \
        objects/(info/[^/]+ | \
        [0-9a-f]{2}/[0-9a-f]{38} | \
        pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
        git-(upload|receive)-pack))$" \
        /usr/lib/git-core/git-http-backend/$1
 
    SetEnv GIT_PROJECT_ROOT /home/git
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
 
    <Location />
        AuthType Digest
        AuthName "Shared Git Repo"
        AuthUserFile /home/git/.htpasswd
        Require valid-user
    </Location>
 
    ErrorLog ${APACHE_LOG_DIR}/gitweb.<domain>-error.log
    CustomLog ${APACHE_LOG_DIR}/gitweb.<domain>-access.log combined
</virtualhost>
</pre>
 
<pre>
sudo a2ensite gitweb.conf
sudo service apache2 reload
</pre>
 
===== https =====
 
SSL-Zertifikat erstellen - dazu siehe [[SSL_Zertifikat]]
 
<pre>
sudo vi gitweb.conf
</pre>
 
<pre>
<VirtualHost *:80>
        ServerName git.<domain>
        ServerAlias git.<domain>
        Redirect / https://git.<domain>
</VirtualHost>
</pre>
 
<pre>
sudo vi gitweb-ssl.conf
</pre>
 
<pre>
<virtualhost *:443>
    ServerName git.kirner.or.at
    DocumentRoot /var/www/gitweb
 
 
    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/git.crt
    SSLCertificateKeyFile /etc/ssl/private/apache.key
 
    <Directory /var/www/gitweb>
        Options +FollowSymLinks +ExecCGI
        AddHandler cgi-script .cgi
        DirectoryIndex gitweb.cgi
    </Directory>
 
    ScriptAliasMatch \
        "(?x)^/(.*/(HEAD | \
        info/refs | \
        objects/(info/[^/]+ | \
        [0-9a-f]{2}/[0-9a-f]{38} | \
        pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
        git-(upload|receive)-pack))$" \
        /usr/lib/git-core/git-http-backend/$1
 
    SetEnv GIT_PROJECT_ROOT /home/git
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
 
    <Location />
        AuthType Digest
        AuthName "Shared Git Repo"
        AuthUserFile /home/git/.htpasswd
        Require valid-user
    </Location>
 
    ErrorLog ${APACHE_LOG_DIR}/gitweb.<domain>-error.log
    CustomLog ${APACHE_LOG_DIR}/gitweb.<domain>-access.log combined
</VirtualHost>
</pre>
 
<pre>
sudo a2ensite gitweb-ssl.conf
sudo service apache2 reload
</pre>
</pre>
==== Beschreibung ändern ====
Die Beschreibung
<pre>
Unnamed repository; edit this file 'description' to name the repository.
</pre>
ändert man durch editieren der Datei
<pre>
<root directory>/<repo>.git/description
</pre>
Bei einem Klon des Repositories wird diese Beschreibung jedoch nicht übernommen.
==== Links ====
[https://git-scm.com/book/de/v1/Git-auf-dem-Server-GitWeb https://git-scm.com/book/de/v1/Git-auf-dem-Server-GitWeb]


== Client Seite ==
== Client Seite ==
Zeile 310: Zeile 171:
[http://www.tikalk.com/devops/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204/ http://www.tikalk.com/devops/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204/]
[http://www.tikalk.com/devops/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204/ http://www.tikalk.com/devops/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204/]


== Zu Git umziehen ==
== Umziehen ==


=== Links ===
[[Von Subversion zu Git umziehen]]
 
== IDE Integration ==


[https://git-scm.com/book/de/v1/Git-und-andere-Versionsverwaltungen-Zu-Git-umziehen https://git-scm.com/book/de/v1/Git-und-andere-Versionsverwaltungen-Zu-Git-umziehen]
[[Git in IntelliJ]]


== Probleme ==
== Probleme ==
Zeile 340: Zeile 203:




Zurück zu [[Ubuntu]]
Zurück zu [[Git Server (unterschiedliche Versionen)|Git Server]]

Aktuelle Version vom 27. Juli 2020, 23:36 Uhr

Noch in Bearbeitung


GitPushForceYoda.jpg Git-push-force.png


Installation

PPA-Repository

sudo add-apt-repository ppa:git-core/ppa

Paket installieren

sudo apt-get update
sudo apt-get install git 

Apache

Packete für htdigest und fcgid installieren:

sudo apt-get install apache2-utils libapache2-mod-fcgid
sudo a2enmod env alias fcgid auth_digest
sudo service apache2 restart

Konfiguration

Ports

Anwendung Protokoll Port
ssh:// TCP 22
git:// TCP 9418
http:// TCP 80
https:// TCP 443

Links

https://git-scm.com/book/de/v1/Git-auf-dem-Server-Die-Protokolle

Projektverzeichnis

Grundverzeichnis erstellen:

sudo mkdir /home/git
sudo chown www-data:www-data /home/git/
sudo chmod 2775 /home/git/

Projektverzeichnis erstellen:

mkdir /home/git/test/
cd /home/git/test/
git --bare init

Der Befehl git --bare init erstellt ein leeres Repository ohne Arbeitsverzeichnis. Darin kann man keine Dateien direkt sehen - benötigt den Befehl git --show.

Allgemein

Um die Lesbarkeit zu erhöhen, sollte man die Ausgaben mit den folgenden Befehlen einfärben:

git config --global color.ui "auto"

Für Computer mit mehreren Prozessorkernen empfiehlt sich diese Option:

git config --global pack.threads "0" 

Als Dämon starten

Upstart

sudo vi /etc/init/git_daemon.conf
description "Git daemon"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 10 5
umask 002

exec /usr/bin/git daemon --user=www-data --group=www-data --reuseaddr --verbose --export-all --base-path=/home/git
sudo initctl start git_daemon
sudo initctl stop git_daemon

Links

https://git-scm.com/book/de/v1/Git-auf-dem-Server-Git-Daemon

Webinterface

GitWeb

GitLab

Repository anlegen

cd /home/git
mkdir project.git
cd project.git
git --bare init

Client Seite

Verwendung von Git wurde nach Git Client verschoben.

Lokales Repository auf Server kopieren

git clone --bare .git test.git
scp -r test.git <user>@<domain>:/home/git/

Links

http://www.codesolutions.de/git-repository-lokal-erstellen-und-dann-auf-den-server-uploaden/

Repository von Server klonen

Verwendung siehe Git Client

Links

https://git-scm.com/docs/git-http-backend

https://kupschke.net/2012/02/23/git-server-mit-apache-und-dem-git-smart-http-protokoll/

http://www.tikalk.com/devops/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204/

Umziehen

Von Subversion zu Git umziehen

IDE Integration

Git in IntelliJ

Probleme

fatal: remote error: access denied or repository not exported: /test.git

Entweder eine leere Datei git-daemon-export-ok im Repository anlegen oder den Dämonen mit der Option --export-all Option starten.

fatal: unable to access 'https://git.<domain>/test.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

SSL-Verifizierung mittels folgendem Befehl deaktivieren:

git config --global http.sslverify false

Links

https://wiki.ubuntuusers.de/Git/

https://www.git-tower.com/learn/

http://t3n.de/news/git-eigener-git-server-544264/

https://git-scm.com/book/de/v1/Git-auf-dem-Server-Git-auf-einen-Server-bekommen


Zurück zu Git Server