Build your own git server on Linux

Source: Internet
Author: User
Tags git clone

Recently encountered the requirements of the GIT service because the project type is special, so I intend to make git backup tool but because the project is relatively large, excluding the public warehouses such as GitHub, can only build a git server, the data are I Baidu, here do a collation, the server is cent OS 7.3

1: Install git (please bypass if installed)

Yum Install git  

2: Install SSH service (installed please bypass) through Ps-ef|grep sshd to see if the system has SSH service

Yum Install Openssh-server openssh-client

3: Create a git user

Useradd git (creating a user named Git) passwd git (Creating a password for a git user)

4: Create a git repository store directory and permissions

Mkdir/home/git/repositorieschown Git:git/home/git/repositorieschmod 755/home/git/repositories

PS: You can change the catalogue according to your own needs.

5: Switch to a git user and build a server repository

Su gitcd/home/git/repositories  (Initializes a warehouse name of test) git init--bare test.git

Finally, verify on the client:

On the client command line input: Git clone [email protected]***.***.**.**:/home/git/repositories/tset.git (* denotes your own IP)

Follow the prompts to enter Yes, and then enter the password for the git user (i.e. the password set above)

Then you can see the test directory on the client, enter this directory, modify the files in this directory, you can push the changes to the server

PS: I met a mistake here.

Warning:remote HOST Identification has changed!

I'm here, Win7. Client enters C:\Users\Administrator\.ssh directory

Edit the known_hosts file to find your corresponding IP line and delete it and save it.

6: The above method and each commit changes to the server will be required to enter the password, more trouble, in order to solve this problem, the client user SSH key can be written to the server-side git user's Authorized_keys file, the specific operation

(1): In the client shell command line input: Ssh-keygen (Here I was entered in Git Bash of Win7 client)

If the Linux client appears ~/.ssh/id_rsa.pub this public key file

If the win client is in the C:\USERS\ADMINISTRATOR\.SSH directory

(2): Upload id_rsa.pub file to git server to ensure git user readable

git server switches to git users

Su  git

Enter and print

Cat id_rsa.pub >> ~/.ssh/authorized_keys   (note the contents of both)

  

Complete, the client restarts the Git Bash clone to see the effect

Article reproduced from http://blog.csdn.net/zhuxiaoping54532/article/details/53813437

Build your own git server on Linux

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.