Linux build git server

Source: Internet
Author: User

Cenos Build a git server

Assuming you already have sudo access to the user account, below, formally start the installation.

First step, install git :

# yum Install git

The second step is to create a git user to run the git service:

# AddUser git

The third step is to create a certificate login:

Git client production into id_rsa.pub, input command

SSH-KEYGEN-T RSA

Id_rsa.pub this file in the C:\Users\Administrator\.ssh directory on the Windows host

id_rsa.pub file, import all public keys into /home/git/.ssh/authorized_keys file, one line at a. You can use  cat id_rsa.pub >> authorized_keys

If Authorized_keys does not exist on the server then touch authorized_keys to create it

The fourth step is to initialize the GIT repository:

Select a directory to use as a git repository and do so in the/home/git directory. I'm working under other directories, but there's always a permissions problem, so it's not wrong to create a warehouse in the/home/git directory.

# git init--bare sample.git

.git ends. Then, change owner to git :

# chown-r Git:git Sample.git

Fifth step, disable the shell login:

For security reasons, the GIT user created in the second step is not allowed to log in to the shell, which can be done by editing the /etc/passwd file. Find a line similar to the following:

git:x:1001:1001:,,,:/home/git:/bin/bash

Switch

git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

git users can use git normally via SSH, but cannot log in to the shell because we are git User-specified git-shell automatically exits every time you log on.

Sixth step, clone the remote repository:

Now, you can git clone clone the remote repository by command and run it on your own computer:

$ git clone [email protected]:/srv/sample.gitcloning into ' sample ' ... warning:you appear to having cloned an empty repositor Y.

The rest of the push is simple.







Deploy the code uploaded to the git server to a truly accessible Web server.

Using commands

Git Clone/home/git/ios.git/var/www/html/api

This will get the code on the GIT server under/var/www/html/api, which is the code you uploaded from the developer's local repository, each time after GIT push Origin master, to the server/var/www/html/api Directory execution git pull pulls the code down is the latest code.



And so on the automatic deployment and then to update the blog


Linux build git server

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.