How to build git server under Linux

Source: Internet
Author: User
Tags ssh file permissions git shell

Objective

GitHub is a remote repository that is free to host open source code. But for some depending on the source code such as life of commercial companies, neither want to open the source code, but also reluctant to give GitHub to pay protection fees, then you can only build a git server as a private warehouse to use.

I'm going to build my own git server. While there are already good git tools, such as github,coding.net, but for security, reduce the restrictions and overhead, or put on your own server for good. The following gives the installation configuration process, there are questions welcome to discuss and exchange, I will promptly reply.

First step

Install Git: You can quickly install by command, different Linux installation methods may not be the same, I am using the Yum method. Ubuntu can use apt-get commands.

 
 

Second Step

Add git users, because the GIT server only limited to do project code Exchange, a dedicated user to access the GIT server, better management and control.

 
 

Third Step

Set the login password for the git user. Because Git provides the SSH protocol login function, some of the online use of the storage client rsa_pub password to avoid the secret landing, but I stored the public key file, modified the SSH configuration, changed the file permissions, the final actual test can not, or when Git access prompts to enter a password. So simply set a password for yourself, it is also safe. The workload is the same as requiring users to send public key files to administrators.

 
 

Fourth Step

Set the permissions of the git login user. In order for Git to log on remotely, only the Git-shell command is allowed, and you need to modify the /etc/passwd file to find git:x:500:500:,,,:/home/git:/bin/bash this line, typically on the last line, instead of noticing that the git:x:500:500:,,,:/home/git:/usr/bin/git-shell numbers are based on your computer's actual situation and may be a different number. After the simple steps above, the GIT environment has been built up.

The following is the fourth step in creating a git project: Creating a warehouse. Can be created from an existing project file directory by first entering the project root directory.

Then enter the following command

 
 

Fifth Step

To modify the owner of a generated. git file as a git user

 
 

Sixth step

The above only creates an empty warehouse and needs to add the project file. The following command is a common operation for Git and is a way to use Git. Interested can learn the relevant commands by themselves

 
 
 
 

After the above steps, the server-side Git project repository has been established. Other people can clone a git server's project file to local. However, you need to first install the Git-shell tool on your own client. For friends who already have the GitHub client installed, it is easy to build git directly with its git shell terminal.

 
 

Summarize

Actually build git server is very simple, usually 10 minutes to complete. The above is the entire content of this article, I hope the content of this article to ah everyone's study or work can bring certain help.

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.