7. Construction and simple operations of git server gitolite

Source: Internet
Author: User
Tags ssh access git commands

Recently, people are relatively lazy. In order to change their skills, they decided to take the time to learn new technologies. These new technologies are currently not very demanding, you only need to get started.

Because I only spent three or four days out of things, Do not spray them. In addition, it is inevitable that there will be errors. If so, please point out.

Environment:

Ubuntu server 14.04.1, git 1.9.1 gitolite3

I will not introduce git here. If you are interested, you can search for it on the Internet.

The following describes how to install the GIT server gitolite, how to create a repository, and how to add users. This article will not introduce too many git commands, because I am not clear about them yet, when can I see it clearly? I will write articles and share them.


1. Build the Ubuntu Environment

I am using Ubuntu installed on a virtual machine. I am using 14.04, And I used 13.04 at the beginning. However, if some software packages do not exist, 14.04 is used for all of them. (For Linux, why is it not possible that it is not set correctly? Do not spray it)

2. Install git

First, we need to install git. Ubuntu provides a very convenient installation tool, Apt-get, so we use this tool for installation, enter the following command in the command line (the server version is the command line, and the desktop version is used to search for the command line ):

Sudo apt-Get update

This command is used to update the resources of software that APT-Get can install.

Sudo apt-Get install git

This command is used to install git (the diamond below is garbled)

3. install OpenSSH-Server

Sudo apt-Get install OpenSSH-Server

Openssh-server is required for SSH access.

4. Add a Management User

Add a user git (or another user name, which is easy to remember). This user is used to manage git, including repository creation and git user addition.

Sudo adduser -- System -- shell/bin/Bash -- group git

Some systems only allow users of specific user groups (such as SSH user groups) to log on through the SSH protocol. Therefore, you need to add new git users to the SSH user group.

Sudo adduser git SSH

Set Password

Passwd git

5. generate an SSH key

Git requires SSH access, so a set of SSH keys need to be generated. For details about SSH access, search for it.

Switch to the GIT user

Su git

Ssh-keygen

CD. SSH

CP id_rsa.pub authorized_keys

6. Install gitolite

Under a git user

Mkdir bin create bin directory for gitolite Installation

Clone gitolite from the remote end

Git clone git: // github.com/sitaramc/gitolite

Run the following command to install

~ /Gitolite/install-~ /Bin
Mv ~ /. Ssh/authorized_keys ~ /Git. Pub
~ /Bin/gitolite setup-PK ~ /Git. Pub

If the following content indicates successful:

7. view the default Repository

Under the GIT user
SSH [email protected]

The following content is displayed:

Hello git, this is [email protected] running gitolite3 v3.5.2-4-g62fb317 on git1.8.1.2
R w gitolite-Admin
R w Testing
Gitolite works properly
After successful installation, gitolite will automatically generate two repositories. One is testing. Git for testing, and the other is gitolite-Admin for managing gitolite configuration warehousing.
Clone the gitolite-admin.git to the local, note: it is still under the GIT user, because currently only git users have read and write permissions on it.

Git clone [email protected]: gitolite-Admin

The gitolite-Admin directory appears under the current directory.

8. Add a git user

You need to generate a public key file for the user you want to add. I will test it in Mac. in Linux, the SSH key generated by git is the same as the above, in Windows, you may need to use msysgit. To generate a pair of files, you need to change XXX. Pub to the user name you want to add. For example, if you want to add a user name as mxy, you need to change id_rsa.pub to mxy. Pub. Run the following command to copy to the gitolite-admin/keydir directory:

SCP <user>. Pub [email protected]: gitolite-admin/keydir: copy the pub Public Key to the gitolite-Admin repository.

Check whether the corresponding file exists in the corresponding directory of the GIT server.

Here, the user only adds a part of the content. After adding the content, let's continue.

9 Add a repository

Open the gitolite-admin/CONF/gitolite. conf file

Modify it to the following content (I, ESC, and WQ are basically used here for self-search of VI commands)

The above repo indicates that a demo repository is created (there are many ways to create it, here I will only introduce this one). The following RW indicates read/write, and there are other keywords, search by yourself. Equals signs indicate the permissions for this warehouse. Multiple users use spaces to separate them.

10. Push the configuration to the gitolite Server

When you go to step 1, do you think it is over? Actually, it is not. Because our gitolite-Admin is cloned, these configurations are only saved locally, so we need to push it to the gitolite server before it will take effect.

Run the following command in the gitolite-Admin directory:

Git add.

Git commit-M ": This is the submission information, used to indicate the interpretation of this submission, You can casually write"

The following error may occur during this step. We need to configure the submit information.

The solution is as follows (of course, the final configuration should be set based on your actual situation ):

The GIT push origin master command is pushed to the server. The above two commands are only for local submission. You can learn about local commit and learn about git.

11. test whether the building is successful

Use the added user to clone the demo library. If the database can be successfully cloned, it indicates that there is basically no problem. I configured the user mxy, so my command line is as follows:

In the above [email protected], git refers to the users who manage git, and the following IP address refers to the IP address of the GIT server. If we can clone democlone, it means the operation is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.