Set up git server gitosis1 in centos

Source: Internet
Author: User

. Compile and install git

Yum install git

2. Install gitosis

    1. $ Yum install Python-setuptools
    2. $ Git clone git: // github.com/res0nat0r/gitosis.git
    3. $ CD gitosis
    4. $ Python setup. py install

Web: https://github.com/res0nat0r/gitosis

3. Generate a public key on the development machine (used to initialize gitosis)

    1. $ Ssh-keygen-t rsa # password not required, just press enter (Local Operation)
    2. $ SCP ~ /. Ssh/id_rsa.pub root @ xxx:/tmp/# upload your SSH Public Key to the server

4. initialize gitosis [server]

    1. $ Adduser git # Add a git user (add the user group groupadd git first)
    2. $ Su git # switch to a git user
    3. $ Gitosis-init </tmp/id_rsa.pub # id_rsa.pub is just passed in. Note that in the/tmp directory, the permission is granted to all users in the directory.
    4. $ RM/tmp/id_rsa.pub # id_rsa.pub is useless and can be deleted.

5. Obtain and configure the gitosis-Admin [client]

    1. $ Git clone git @ xxx: gitosis-admin.git # Switch to the root user and execute locally, get gitosis management project, will generate a gitosis-Admin directory, which contains the configuration file gitosis. conf and a keydir directory. The keydir directory stores the GIT user name.
    2. $ VI gitosis-admin/gitosis. conf # edit the gitosis-Admin configuration file

If you cannot clone git, you can use git clone git @ xxx:/home/git/repositories/gitosis-admin.git

# Add at the bottom of gitosis. conf

    1. [Group group name]
    2. Writable = project name
    3. Members = user # the username here must be the same as the file name in keydir

# Pressing ZZ (uppercase) twice in VI will automatically save and exit, and then execute

    1. $ CD gitosis-Admin
    2. $ Git add.
    3. $ Git commit-a-m "XXX xx" # Remember that if you add a new file each time, you must execute git Add ., or git add filename. If there is no new file added, You can execute this sentence simply by modifying it.

# After modifying the file, you must push it to the server; otherwise, the modification will not take effect.

    1. $ Git push

If the error "ddress 192.168.0.77 maps to bogon, but this does not map back to the address-possible break-in attempt!" is reported during git push !", To modify the/etc/hosts file, write the corresponding relationship between the IP address and the host name.

Note:We have not made any changes here. Now there is only one project to manage git. The following is the configuration of the newly added project, which is frequently used by the following operations.

Create a project

In this step, gitosis Initialization is completed. The next step is to create a new project to the server. For example, in step 1, configure the gitosis. conf file to add

    1. [Group project1] # group name
    2. Writable = project1 # project name
    3. Members =Xxx# The user name xxx must be exactly the same as the user name used by the client. Otherwise, no operation is permitted.

Submit the changes and update them to the GIT server.

    1. $ Git commit-a-m "Add a new project project1. The directory of the new project is project1, and the member of this project is custom in XXX "# "".
    2. $ Git push

Submit the newly created Project to the GIT server for registration. So that customers can operate on new projects.

# Create a project directory on the client(Client, the current user is XXX)

Now return to the developer client, where a new project project1 is created and submitted to the GIT server. The information of this project is created here. Note that the project name project1 must be consistent with the configuration in the gitosis. conf file,

    1. $ Mkdir/home/user/project1
    2. $ CD/home/user/project1
    3. $ Git init
    4. $ Git Add. # Add a file. Note the following:
    5. $ Git commit-a-m "initialize project project1 ″

# Put the project on the GIT server.

    1. $ Git remote add origin git @ xxx: project1.git # XXX is the server address
    2. $ Git push origin master

# Combine the above two steps

    1. $ Git push git @ xxx: project1.git master

Note: If the following error is prompted when you execute git push origin master:
Error: SRC refspec master does not match any.
Error: failed to push some refs to 'git @ 192.168.0.77: pro2.git'

This is because the project is empty. We create a new file in the project directory. After-> Add-> commit-> push, you can solve the problem.

    1. $ Touch a.txt
    2. $ Git add a.txt
    3. $ Git commit-a-m'add a.txt'
    4. $ Git push

Bytes ------------------------------------------------------------------------------------------------

If you encounter"

Error: cannot run SSH: no such file or directory-cygwin git

"Error, indicating that the SSH command is not installed on the local machine. For installation methods, see: http://blog.haohtml.com/archives/13313

Sometimes we need to change the computer to re-develop the project. At this time, you only need to put the id_rsa private key in the. Ssh directory in the home directory. (Sometimes, when one person develops multiple projects, the system may prompt that the id_rsa file already exists. I don't know how to solve it here ???)

Related Article

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.