Transferred from: http://blog.chinaunix.net/uid-20620288-id-3152615.html
The setup of Git server under Ubuntu.
A few days ago the teacher assigned a task is to configure the Git server, to manage the project, make a few days, in the online search tutorial search case But write is very general, and some write very good but according to what they said will appear a variety of problems. Today, I took the time to record the details of my configuration of the Git server, hoping to help everyone.
4 steps to build a git server
1 preparation before configuring the server
The Ubuntu system first installs the Git,openssh-server and openssh-client software on the Internet and detects if it is turned on.
Rpm-qa | Grep-i git (see if Git is installed)
sudo apt-get install git
sudo apt-get install Openssh-server
sudo apt-get install openssh-client
2 Adding a git user
New user git, who will be the manager of all code warehouses and user rights:
[email protected]:~$ sudo useradd-m git
[email protected]:~$ sudo passwd git
Create a storage point for a git repository, and set permissions so that users other than git have no access to this directory.
[Email protected]:~$ sudo mkdir/home/pro_j
(Create a directory, as a storage point.) )
[Email protected]:~$ sudo chown git:git/home/pro_j
(Put Pro_j permissions to git)
[Email protected]:~$ sudo chmod 755/home/pro_j (set file Pro_j to rwxr_xr_x without any access to this directory for users other than Git)
3 Installation Configuration Gitosis
The git user who initializes the server can view it with Cat ~/.gitconfig
[email protected]:~$ git config--global user.name "your name"
[email protected]:~$ git config--global user.email your email
[Email protected]:~$ cat ~/.gitconfig
[user] name = Zhang Mingjie
email = [email protected]
Install Python's setuptool and prepare it for gitosis:
[Email protected]:~$ sudo apt-get install Python-setuptools
Get Gitosis Package:
[Email protected]:~$ mkdir OSIs
[Email protected]:~$ cd OSIs
[Email protected]:~/osis$ git clone git://eagain.net/gitosis.git
Note: An error occurred while performing the previous step
Cloning into gitosis ...
EAGAIN.NET[0:208.78.102.120]: Errno=connection refused
Fatal:unable to connect a socket (Connection refused)
You can use: Git clone https://github.com/res0nat0r/gitosis.git instead
[Email protected]:~/osis$ cd gitosis
[email protected]:~/osis/gitosis$ sudo python setup.py install by default, Gitosis will place the Git repository in the repositories under Git user home, So make a link: [Email protected]:~/osis/gitosis$ su git
$ ln-s/home/pro_j/home/git/repositories
$ exit
Become an administrator: either this machine can be administrator by generating the SSH public key method
[Email protected]:~$ ssh-keygen-t RSA generated keys can be found in the ~/.ssh file.
To build the administrator on the server:
[Email protected]:~/osis/gitosis$ sudo chmod a+r ~/.ssh/id_rsa.pub
[sudo] password for Geiao:
Let Gitosis run up:
[Email protected]:~/osis/gitosis$ sudo-h-u git gitosis-init< ~/.ssh/id_rsa.pub
Initialized Empty Git repository in/home/pro_j/gitosis-admin.git/
reinitialized existing Git repository in/home/pro_j/gitosis-admin.git/
If you build an administrator on another machine, you must copy the public key (renamed) of that machine to the server and modify the address of the underlined operation.
Gitosis through a git repository to manage the configuration file, the repository is placed in/home/pro_j/gitosis-admin.git. Therefore, to add executable permissions to a file:
[Email protected]:/home/git$ sudo passwd root
[Email protected]:/home/git$ su
[Email protected]:/home/git# CD repositories
[Email protected]:/home/git/repositories# cd Gitosis-admin.git
[Email protected]:/home/git/repositories/gitosis-admin.git# sudo chmod 755/home/pro_j/gitosis-admin.git/hooks/ post-update [Email protected]:/home/git/repositories/gitosis-admin.git# exit
4 managing Configuration files for Gitosis
The configuration of gitosis itself is also implemented through GIT. In your own development machine, the Gitosis-admin.git This repository clone down, you can modify the configuration as an administrator.
[Email protected]:~$ cd OSIs
[Email protected]:~/osis$ mkdir Pro
[Email protected]:~/osis$ CD Pro
[Email protected]:~/osis/pro$ git clone [email protected] Server Ip:gitosis-admin.git
[Email protected]:~/osis/pro$ cd gitosis-admin
[Email protected]:~/osis/pro/gitosis-admin$ ls
Gitosis.conf Keydir
gitosis.conf files and Keydir folders
The primary role of the gitosi.conf file is that administrators can write permissions to other people, write to members of Gitosis-admin, or write permissions to warehouses: Writable and readonly. Set permissions here to establish group settings.
The Keydir folder is where other people's public keys are stored. and must be aware of who's public key whose name is required to store it.
[email protected]:~/osis/pro/gitosis-admin/keydir$ ls [email protected] jghost.pub Otherwise it will appear:
ERROR:gitosis.serve.main:Repository Read access Denied
After the configuration is necessary to do things to commit gitosis-admin changes, and commit and then git push, and you do not need to build good one empty warehouse on the server, and then import the project. Gitosis will be created automatically when you build your project and push it to the server. Then you can build a project like Proj.git (which is more important)
[Email protected]:~/osis/pro$ mkdir proj
[Email protected]:~/osis/pro$ CD proj
[Email protected]:~/osis/pro/proj$ git init
Initialized Empty Git repository in/home/geiao/osis/pro/proj/.git/
[Email protected]:~/osis/pro/proj$ Touch README
[Email protected]:~/osis/pro/proj$ git add README
[Email protected]:~/osis/pro/proj$ git commit-a-M "Add Readme"
[Email protected]:~/osis/pro/proj$ git remote add origin [email protected]:proj.git
[email protected]:~/osis/pro/proj$ git push Origin master
To this, the establishment of a GIT server on Ubuntu is basically done.
As for Gitweb interested can refer to this article.
Http://www.cnblogs.com/xl19862005/archive/2011/06/28/2092464.html
Thank you.
Ubuntu under Git server build "turn"