Build Git server Gitosis under CentOS

Source: Internet
Author: User
Tags macbook

1. compile and install gitSql code 1 $ wget http://kernel.org/pub/software/scm/git/git-1.7.3.tar.gz # current Latest Version 2 $ tar-xzvf git-1.7.3,tar.gz # unzip out 3 $ cd git-1.7.3 # Enter directory 4 $ yum install-y gettext-devel expat-devel curl-devel zlib-devel openssl-devel #-y is automatically installed by default, $5. /configure -- with-curl =/usr/local # git installation path 6 $ make & make install # To minimize the installation of CentOS, there is no make, you can run yum install make to install 7 $ git -- version # To check the version number. Check whether git is successfully installed. 2. install gitosisSql code 1 $ yum install python-setuptools 2 $ git clone git: // eagain.net/gitosis.git 3 $ cd gitosis 4 $ python setup. py install 3. generate a Public Key (used to initialize gitosis) on the development machine SQL code 1 $ ssh-keygen-t rsa # password is not required, just press enter (locally) 2 $ scp ~ /. Ssh/id_rsa.pub root @ xxx:/tmp/# upload your ssh public key to the server

When git encounters such a problem

Agent admitted failure to sign using the key.
Permission denied (publickey ).

Run ssh-add.

4. initialize gitosisSql code 1 $ adduser git # Add a git user 2 $ su-git # Switch to the git user 3 $ gitosis-init </tmp/id_rsa.pub # id_rsa.pub is just passed in 4 $ rm/tmp/id_rsa.pub # id_rsa.pub is useless, deletable. 5. get and configure gitosis-adminSql code 01 $ git clone git @ xxx: gitosis-admin.git # Run locally and get gitosis Management Project 02 $ vi gitosis-admin/gitosis. conf # edit gitosis-admin configuration file 03 # In gitosis. add 04 [group name] 05 writable = project name 06 members = user # the username here must be the same as the file in keydir. Consistent name 07 # Press ZZ (uppercase) twice under VI to automatically save and exit, run "08 $ git commit-a-m" xxx xx "# Remember That git add ., or git add filename. If there is no new file, you can execute this sentence only after modification. 09 # After modifying the file, you must PUSH it to the server; otherwise, the modification will not take effect. 10 $ git push use git-bash in windows to generate ssh-keygen-t rsa1. generate A public/private key pair on host. [Chenlb @ A ~] $ Ssh-keygen-trsa-p''
-P indicates the password.-P ''indicates that the password is empty, or you do not need the-P parameter. In this case, you have to press enter three times and press enter once with-P.
It generates the. ssh directory under/home/chenlb, and id_rsa and id_rsa.pub under. ssh.

2. Copy id_rsa.pub under machine A to machine B. In the. ssh/authorized_keys file of machine B, I use scp to copy.
[Chenlb @ A ~] $ Scp. ssh/id_rsa.pubchenlb@192.168.1.181:/home/chenlb/id_rsa.pub
Chenlb@192.168.1.181 'spassword:
Id_rsa.pub100 % 2230.2KB/s00: 00
Because no password-free logon is available, you need to enter the password.

3. Machine B adds id_rsa.pub copied from machine A to the. ssh/authorzied_keys file.
[Chenlb @ B ~] $ Catid_rsa.pub>. ssh/authorized_keys
[Chenlb @ B ~] $ Chmod600.ssh/authorized_keys
The authorized_keys permission is 600.


Windows client to use tortorisePLink connection, and configure the repo, to write all the paths, and do not add the branch name git@88.88.88.88: repositories/hello. git
Cd repositories
git init --bare project1.git
After creating a project, you can initialize gitosis. Next, create a new project to the server, for example, configure gitosis in step 1. the conf file is added with SQL code 01 [group project1] # group name 02 writable = project1 # project name 03 members = xxx # username xxx is the same as members in [group gitosis-admin] 04 # Remember to execute the SQL code 01 $ git commit-a-m "to add a new project project1, the Directory of the new project is project1, the member of this project is the custom content 02 $ git push 07 # enter the project directory SQL code 01 $ cd/home/user/project1 # project1 to be associated with gitosis. conf file configurations are consistent 02 $ git init 03 $ git add. # add a new file. Pay attention to the following: 04 $ git commit-a-m "initialize project project1" 12 #. Then, place the project on the server. SQL code 01 $ git remote add origin git @ xxx: project1.git # xxx is the server address 02 $ git push origin master 15 # You can also combine the above two steps into one step SQL code 01 $ git push git @ xxx: project1.git master

7. Create a new repositories

Open the gitosis. conf file and you will see

[Group gitosis-admin]

Writable = gitosis-admin

Members = elton @ macbook

This is the Management Group permission. The username in members is the username in the uploaded public key.

Add the following content to the file:

[Group myteam]

Members = elton @ macbook

Writable = free_monkey

Here you define a group named myteam and grant the repo permission to the elton @ macbook user to write "free_monkey ".

Git commit-a-m "Allow elton write access to free_monkey"

Git push

The above operation updates the server's permissions.

Create a repo for free_monkey.

Mkdir free_monkey

Cd free_monkey

Git init

Create a. gitignore file to ignore some content that does not require code management. For example, the rails application may be as follows:

. DS_Store

Log/*. log

Tmp /**/*

Config/database. yml

Db/*. sqlite3

Code submission:

Git remote add origin git @ YOUR_SERVER_HOSTNAME: free_monkey.git

Git add.

Git commit-a-m "initial import"

Git push origin master: refs/heads/master

Next, you can add the Member's public key to the system.

Cd gitosis-admin

Cp ~ /Alice. pub keydir/

Cp ~ /Bob. pub keydir/

Git add keydir/alice. pub keydir/bob. pub

Modify gitosis. conf

[Group myteam]

-Members = jdoe

+ Members = jdoe alice bob

Writable = free_monkey

Submit changes:

Git commit-a-m "Granted Alice and Bob commit rights to FreeMonkey"

Git push

Other members can get the code.

Git clone git @ YOUR_SERVER: free_monkey.git

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.