Git Server Build
In the previous section, our remote warehouse used Github,github public projects for free, but if you don't want others to see your project, you'll need to charge for it.
Then we need to build a git server to use as a private warehouse.
Next we'll build a Git server as an example of Centos.
1, install Git
$ yum Install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum Install git
Next we create a git user group and user to run the GIT service:
$ groupadd git
$ adduser git-g git
2. Create Certificate Login
Collects the public key of all users who need to log in, the public key is located in the Id_rsa.pub file, and the public key is imported into the/home/git/.ssh/authorized_keys file, one line.
If you do not have the file to create it:
$ cd/home/git/
$ mkdir. SSH $ chmod. SSH $ touch
. Ssh/authorized_keys
$ chmod S
3. Initialize git repository
First we select a directory as a git repository, assuming it is/home/gitrepo/w3cschoolcc.git, and enter the command in the/home/gitrepo directory:
$ cd/home
$ mkdir gitrepo
$ chown git:git gitrepo/
$ cd gitrepo
$ git init--bare w3cschoolcc.git
Ini tialized Empty Git repository in/home/gitrepo/w3cschoolcc.git/
The above command git creates an empty warehouse, and the GIT repository on the server usually ends with. Git. Then, change the user who owns the warehouse to git:
$ chown-r Git:git W3cschoolcc.git
4. Cloning Warehouse
$ git clone git@192.168.45.4:/home/gitrepo/w3cschoolcc.git
cloning into ' W3CSCHOOLCC ' ...
Warning:you appear to have cloned a empty repository.
Checking connectivity ... done.
192.168.45.4 for git's server IP, you need to modify it for your own git service IP.
So our git server Setup is complete, and then we can disable the git user login through the shell, which can be done by editing the/etc/passwd file. Locate a line similar to the following:
Git:x:503:503::/home/git:/bin/bash
To
Git:x:503:503::/home/git:/sbin/nologin