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.