Build git server with no basic centos6 and solve common problems

Source: Internet
Author: User

1. Compile and install git

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 it 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 gitosis1 $ Yum install Python python-setuptools2 $ git clone git: // eagain.net/gitosis.git3$ CD gitosis4 $ Python setup. py install 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 [email protected]:/tmp/# upload your SSH Public Key to the server. Problem: incorrect port number method: SCP-P port number... # large P Source: http://xinkang120.blog.163.com/blog/static/1946682232011913112859564/ problem: In git bash copy and paste Method: In the bash command line interface right-click the top left corner, "attribute"-"" quick edit mode "-" OK ". Right-click and paste it. Source: http://www.tuicool.com/articles/NRj2Af

4. Generate git users on the server, use git users, and initialize gitosis

Add User git:

# Useradd-r-s/bin/sh-C 'git version control'-D/home/git

Set permissions:

# Mkdir-P/home/git

# Chown git: git/home/git

 

Generate a management database on the server:

# Sudo-H-u git gitosis-init <~ /Id_rsa.pub

Initialized empty git repository in/home/git // repositories/gitosis-admin.git/reinitialized existing git repository in/home/git/repositories/gitosis-admin.git/

Note:

1. The generated gitosis-Admin is the GIT user access permission management library. gitosis manages the access permissions of all git libraries through this git library.

2. After initialization, the owner of the public key can modify the special git repository used to configure gitosis.

 

Modify the upload permission:

# Chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-Update

5. CLIENT Export Management

# Mkdir-P/Git-repo/

# Cd/Git-repo/

# Git clone [email protected]: gitosis-admin.git

My code: git clone SSH: // [email protected]: 27390/gitosis-admin.git

 

# Cd gitosis-Admin

# Find.

./gitosis.conf

./keydir

./keydir/[email protected]

Note:

gitosis.confControl file used to set users, warehouses, and permissions

The keydir directory stores all the places with the public key of the user with access permissions.

./Keydir/[email protected]: As described earlier, this user has access permissions.

 

6. Create and set a management project on the client

# Cd/Git-repo/gitosis-Admin

View uploaded keys

# Ls keydir/

[Email protected]

 

Authorization and permission Control

# Vim gitosis. conf

[Gitosis]

[Group gitosis-admin]
Writable = gitosis-Admin
Members = [email protected] # display that the user [email protected] is the owner of the initialized gitosis public key and the only person who can manage the gitosis-Admin Project

[Group jay_fans] # group name
Members = [email protected] # key Username
Writable = Git-test # project name

 

7. Initially, add and use the project Git-test

# Cd/Git-Repo

# Mkdir Git-test

# Cd Git-test

# Git init

# Touch readme

# Git add.

# Git commit-a-m "init Git-test"

# Git remote add origin [email protected]: git-test.git

# Git push origin master

Note: Before pushing data to the server for the first time in the new project Git-test, you must set the server address as a remote repository, however, you do not need to manually create the bare repository of the project on the server beforehand-gitosis will be automatically created when the first push is encountered.

Problem:

Please tell me who you are.

Git config -- global user. Email "[email protected]"
Git config -- global user. Name "your name"

Cause: no account is created.

Solution:

$ git config --global user.email "[email protected]"

 

$ git config --global user.name "lenky.gao"

 

Source: http://www.tuicool.com/articles/Qjaqqu

 

Problem: git pushes origin master

Initialized empty git repository in/home/git/repositories/t18.git/
Error: SRC refspec master does not match any.
Error: failed to push some refs to 'ssh: // [email protected]: 27390/t18.git'

Cause: there are no files in the directory, and empty directories cannot be submitted.

Solution:

$ CD myproject
$ Git init
$ Git add.
$ Git commit-m'initial commit'
$ Git remote add origin [email protected]:/opt/git/Project. Git
$ Git push origin master

Source: http://www.open-open.com/lib/view/open1366080269265.html

 

8. Add other member public keys on the client to the system: add the user's public key to the keydir directory.

# Cd/Git-repo/gitosis-Admin

# Cp/path/to/member/public/key keydir/

# Git add keydir/member. Pub

Modify gitosis. conf

[Group jay_fans] # group name
Members = Jay # New Key Username
Writable = Git-test

 

Submit changes:

# Git commit-a-m "granted Jay commit rights to git-test"

# Git push

Note: gitosis is actually a slave server/home/git /. gitosis. if the conf file reads information, the new permission information will be written to the file through the above operations. If the configuration is incorrect, the push permission will be lost, you can modify the file to reset it. If you manually edit the file, it will be maintained until the next timegitosis-adminPush the configuration content of the new version.

 

Run the following command to obtain the Code:

# Git clone [email protected]: git-test.git

 

Original tutorial address:

Http://www.centoscn.com/CentosServer/ftp/2014/0414/2789.html

Http://zwm-xl.blog.sohu.com/170050241.html

Http://blog.chinaunix.net/uid-26611973-id-3373977.html



 

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.