It takes some time to configure the Git server and client. As before, it is still based on the latest Ubuntu11.10server/desktop system. Note: Git is a distributed management tool, so there is no real Server. This article uses three machines, S1 representing Ubuntu11.10serverC1 in the data center representing the first ubuntu1_topc2 with administrative permissions.
It takes some time to configure the Git server and client. As before, it is still based on the latest Ubuntu11.10 server/desktop system.
Note: Git is a distributed management tool, so there is no real Server. This article uses three machines, which are
S1 represents the Ubuntu 11.10 server in the IDC
C1 represents the first Ubuntu desktop with administrative permissions
C2 represents the later added Ubuntu desktop with management Permissions
All three machines can be considered as servers. From the perspective of convenience, project files are always submitted to S1, and the latest project files are obtained from S1.
1. Install the Git service program on Ubuntu server
This Ubuntu server is called S1
[Plain]
- Sudo apt-get install git-core
2. Install the Gitosis program on S1.
Gitosis is a tool program that can help us with Git repository access control and remote management.
[Plain]
- Sudo apt-get install python-setuptools
- Mkdir ~ /Src
- Cd ~ /Src
- Git clone git: // eagain.net/gitosis.git
- Cd gitosis
- Sudo python setup. py install
3. Create a git account on S1.
No password. This account is used by the Gitosis program.
[Plain]
- Sudo adduser \
- -- System \
- -- Shell/bin/sh \
- -- Gecos 'git version control '\
- -- Group \
- -- Disabled-password \
- -- Home/git \
- Git
4. Install the remote management client
The first remote management client is called C1.
[Plain]
- Sudo apt-get install openssh-client
- Ssh-keygen
If openssh-client is not installed, the first line of command is required. The ssh-keygen command creates a public key and a private key file. Copy the public key file to the server. After being imported to Gitosis on S1, C1 can connect to the server through SSH without the user name and password.
[Plain]
- Scp/home/chenshu/. ssh/id_rsa.pub cncm @ S1:/home/cncm
- Sudo-H-u git gitosis-init
The following result is displayed:
Initialize empty Git repository in/home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in/home/git/repositories/gitosis-admin.git/
It means that the repository directory has been successfully created on S1. The path is/home/git/repositories, and an administrator repository named gitosis-admin is also created.
Modify the permissions of a file on S1:
[Plain]
- Sudo chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-update
Clone the gitosis-admin repository From S1 to C1:
[Plain]
- /Home/chenshu/my_git
- Cd ~ /My_git
[Plain]
- Git clone git @ S1: gitosis-admin.git
- Cloning into gitosis-admin...
- Remote: Counting objects: 5, done.
- Remote: Compressing objects: 100% (4/4), done.
- Remote: Total 5 (delta 1), reused 5 (delta 1)
- Grouping objects: 100% (5/5), done.
- Resolving deltas: 100% (1/1), done.
Now you can remotely manage the repository on S1 by modifying the gitosis-admin/gitosis. conf file:
[Plain]
- [Gitosis]
- [Group gitosis-admin]
- Members = chenshu @ chenshu-System-Product-Name
- Writable = gitosis-admin
The above is automatically created when gitosis initialized the public key imported into C1. The C1 user has been added to the Administrator.