git server installation
Post on 31-Oct-2015
84 Views
Preview:
DESCRIPTION
TRANSCRIPT
-
Installation eine lokalen Git Servers Resch Andreas
1
Installation eine lokalen Git Servers unter Virtual Box Debian mit grafischer Oberflche Resch Andreas
14.5.2013
Inhalt
1 Git Server-Konfiguration ............................................................................................................ 2
2 Netzwerk Virtual Box Einstellungen ........................................................................................... 2
3 Vorarbeiten (User root) .............................................................................................................. 3
4 Installation (User root) ............................................................................................................... 4
4.1 Im ersten Schritt werden am Server die Pakete git und gitweb installiert:........................... 4
4.2 Linux User chris anlegen .................................................................................................... 5
5 Einrichten des ffentlichen Remote Repository (User root) ....................................................... 5
6 Erstellen einer lokalen Working Copy (User chris) .................................................................... 6
7 Verffentlichung ber http ......................................................................................................... 8
7.1 gitweb ................................................................................................................................. 8
7.2 Activate Read/Write Access ................................................................................................ 9
8 Project ber Eclipse erstellen und im Git Server ablegen........................................................ 12
9 Push / Commit Mit Eclipse ....................................................................................................... 17
9.1 ? bei GIT is Fun hinzufgen .............................................................................................. 17
9.2 Kontrolle in der Weboberflche ......................................................................................... 18
10 Quellen ................................................................................................................................. 20
-
Installation eine lokalen Git Servers Resch Andreas
2
1 Git Server-Konfiguration Der folgende Anleitung erklrt die Installation und Konfiguration eines Git-Servers. Die hier gezeigten Beispiele und Konfigurationen wurden auf einem Debian-Server "squeeze" und Virtual Box durchgefhrt.
2 Netzwerk Virtual Box Einstellungen
Damit der virtualisierte Debian Rechner ins Internet darf und auch aus dem Internet zugreifbar ist, mu die Netzwerkkonfiguration angepasst / kontrolliert werden: die Netzwerkkonfiguration auf "Bridged" ndern.
NAT: die virtuelle Maschine kann auf das Internet zugreifen, umgekehrt geht nur ber Port Forwarding Bridged: die virtuelle Maschine steht wie ein eigener, separater Server im Netzwerk bereit
-
Installation eine lokalen Git Servers Resch Andreas
3
3 Vorarbeiten (User root) Linux Paketverwaltung berprfen: dazu die Datei sources.list im Verzeichnis /etc/apt ansehen
oder einfach:
-
Installation eine lokalen Git Servers Resch Andreas
4
4 Installation (User root)
4.1 Im ersten Schritt werden am Server die Pakete git und gitweb installiert: apt-get install git gitweb
-
Installation eine lokalen Git Servers Resch Andreas
5
4.2 Linux User chris anlegen adduser chris pwd chris For each commit we make while using GIT, a name and email are necessary, let's introduce ourself - connect to server as user "chris" git config --global user.name "chris" git config --global user.email chris@youremail.com
To check if the user as been recorded
git config -l
It will show
user.name=chris user.email=chris@youremail.com
5 Einrichten des ffentlichen Remote Repository (User root) Es folgen nun die Konfigurations-Schritte, die ntig sind, um ein Repository ber http freizugeben und via gitweb erreichen zu knnen. Im ersten Schritt wird ein Verzeichnis erstellt, in dem sich das Repo befindet. Da es sich um ein ffentliches Repo handeln soll, wird ein bare-Repository (im Home Verzeichnis des Users git) angelegt: cd /var/cache/git
mkdir test001
cd test001
git --bare init
ls
Wie oben in der Ausgabe des ls-Befehls ersichtlich gleicht ein bare-Repo nicht einer herkmmlichen Working-Copy.
-
Installation eine lokalen Git Servers Resch Andreas
6
Die Dateien, die sich normalerweise im .git Ordner befinden, sind hier direkt ersichtlich. Die "normalen" Dateien jedoch (an denen gearbeitet wird) befinden sich nicht direkt im Repo, sind aber natrlich ber die verwaltete Historie des Repos zugnglich. Bare-Repos sind speziell fr die Verffentlichung von Repos gedacht, da durch sie immer der letzte Stand des Repos geklont und in das Repo auch gefahrlos gepusht werden kann, da keine Working Copy vorhanden ist.
6 Erstellen einer lokalen Working Copy (User chris) Now let's create a working folder in my home folder mkdir ~/projects/ cd ~/projects git clone /var/cache/git/test001 test001.git
Let's change the project description in this file : ~/projects/test001.git/.git/description My first GIT project - Hello World
Let's exclude some annoying files from the commits, add in this file: /projects/test001.git/.gitignore cd ~/projects/test001.git echo .DS_Store >> .gitignore echo Thumb.db >>.gitignore git add .gitignore git commit -a -m "gitignore configured"
Now the working folder is ready, let's create the first file ~/projects/test001.git/test001.php
For now, GIT still does not recognize the file test001.php. We need to explicitly add the file to tell GIT to start tracking it cd ~/projects/test001.git git add test001.php
Status will show you that the file is still not commited git status
git commit -a -m "My very first commit"
-
Installation eine lokalen Git Servers Resch Andreas
7
(-a is for ALL FILES, -m for Message associated to this commit)
To see history git log
To push your commit to the server this simple command will do it git push origin master
NB: if you are not doing this test with root, you won't be allowed to push yet, the security is setup later on this page:
User chris:
User root: su root
git push origin master
And if you want to download the changes made by somebody else
-
Installation eine lokalen Git Servers Resch Andreas
8
su root git pull
In conclusion for this section, the folder ~/projects/test001 allowed us to verify that everything works perfectly locally, without SSH or HTTP connexion. If your PUSH and PULL works properly here, you can continue to the next section.
7 Verffentlichung ber http Im nchsten Schritt wird der Apache-Webserver so konfiguriert, dass das Verzeichnis des public-Repositories zugnglich wird. Daraufhin knnen alle, die mit dem aktuellen Stand des Repos arbeiten wollen, diesen ber "git clone" auf die eigene Maschine holen.
7.1 gitweb It creates the following folder cd /usr/share/gitweb
The location for publishable repository is defined by the variable $projectroot from /etc/gitweb.conf, which happens to be /var/cache/git
With a standard Apache install, because of the file /etc/apache2/conf.d/gitweb my repository is now viewable at http://server.domaine.com/gitweb/
Das Projekt test001 anklicken
-
Installation eine lokalen Git Servers Resch Andreas
9
7.2 Activate Read/Write Access Before early 2010, WebDAV was the only solution in order to commit to the server via HTTP. It was a very slow process. Now WebDAV is useless, the SMART HTTP method allows the use of POST, with only one file containing everything (much faster) . We will use the rewriting capabilities of Apache a2enmod rewrite
/etc/init.d/apache2 restart
But if you want to allow your client to PUSH (their COMMIT) into your repositories, you will have to change the folder access in order to allow www-data to write chown -R root.www-data /var/cache/git/test001 chmod -R g+w /var/cache/git/test001
Create /etc/apache2/sites-available/git for http://git.company.com (192.168.0.102) #The following commented lines are for a HTTPS server instead of unsecured HTTP # # #SSLEngine on #SSLCertificateFile /etc/ssl/private/server.crt #SSLCertificateKeyFile /etc/ssl/private/server.key #SSLCertificateChainFile /etc/ssl/private/bundle.crt #if you uncomment the previous lines, also uncomment the last line of the file and comment the following one:
-
Installation eine lokalen Git Servers Resch Andreas
10
SetEnv GITWEB_CONFIG /etc/gitweb.conf SetEnv GIT_PROJECT_ROOT /var/cache/git SetEnv GIT_HTTP_EXPORT_ALL ServerName 192.168.0.102
DocumentRoot /usr/share/gitweb AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/cache/git/$1 AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/cache/git/$1 ScriptAliasMatch \ "(?x)^/(.*?)\.git/(HEAD | \ info/refs | \ objects/info/[^/]+ | \ git-(upload|receive)-pack)$" \ /usr/lib/git-core/git-http-backend/$1/$2 #ScriptAlias / /usr/share/gitweb/ AuthType Basic AuthName "git repository" AuthUserFile /var/cache/git/htpasswd.git AuthGroupFile /var/cache/git/htgroup.git Require group cloners AuthType Basic AuthName "git repository" AuthUserFile /var/cache/git/htpasswd.git AuthGroupFile /var/cache/git/htgroup.git Require group commiters AuthType Basic AuthName "git repository" AuthUserFile /var/cache/git/htpasswd.git AuthGroupFile /var/cache/git/htgroup.git Require group test001-read AuthType Basic AuthName "git repository" AuthUserFile /var/cache/git/htpasswd.git AuthGroupFile /var/cache/git/htgroup.git Require group test001-write Options ExecCGI FollowSymLinks Indexes Allow from all Order allow,deny AddHandler cgi-script cgi DirectoryIndex index.cgi RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.* /index.cgi/$0 [L,PT] #
And enable this site a2ensite git
-
Installation eine lokalen Git Servers Resch Andreas
11
/etc/init.d/apache2 reload
Create the password file with a first user (chris) and choose a password for him htpasswd -c /var/cache/git/htpasswd.git chris
If you want to add a second user htpasswd /var/cache/git/htpasswd.git user2
Then create the following groups by creating the file /var/cache/git/htgroup.git vi /var/cache/git/htgroup.git test001-read:chris user2 user3 test001-write:chris user2 commiters:chris cloners:chris user2 user5
NB: cloners/commiters will have access to every repository except test001 which have its own groups test001-read/test001-write NB2: each write access must be allowed in couple with a read access (Write access does not work without read access) The folder must be writable by apache. An easy way to keep writing rights for CHRIS and Apache is: chown -R chris.www-data /var/cache/git/test001 chmod -R 770 /var/cache/git/test001
It should work, from now you have:
Git Repository : http://192.168.0.102/test001.git/
-
Installation eine lokalen Git Servers Resch Andreas
12
Web Interface : http://192.168.0.102/test001/
Web interface for all the repositories : http://192.168.0.102/git
8 Project ber Eclipse erstellen und im Git Server ablegen Java Project, Class
Anbindung an Git:
-
Installation eine lokalen Git Servers Resch Andreas
13
Projekt in lokales Repository stellen: remote GIT Server definieren
-
Installation eine lokalen Git Servers Resch Andreas
14
-
Installation eine lokalen Git Servers Resch Andreas
15
Rechte Maustaste auf Origin:
-
Installation eine lokalen Git Servers Resch Andreas
16
-
Installation eine lokalen Git Servers Resch Andreas
17
9 Push / Commit Mit Eclipse
9.1 ? bei GIT is Fun hinzufgen
-
Installation eine lokalen Git Servers Resch Andreas
18
9.2 Kontrolle in der Weboberflche
-
Installation eine lokalen Git Servers Resch Andreas
19
-
Installation eine lokalen Git Servers Resch Andreas
20
10 Quellen http://www.thomas-krenn.com/de/wiki/Git_Server-Konfiguration http://www.blogix.net/2009/06/23/debian-archive-signing-keys-aktualisieren/ http://wiki.debian.org/SourcesList http://packages.debian.org/de/squeeze/git-all http://wiki.gonzofamily.com/a/Install_GIT_as_public_repository_on_Debian
top related