Environment: centos7
Without further ado, go directly to the tutorial:
Check that git has been followed on the server
rpm -qa git
Copy the code
Install git
yum install git
Copy the code
When a confirmation message is displayed during the installation, enter y
After the installation, check the Git version
git --version
Copy the code
Initialize the warehouse
git --bare /data/MyRepo.git
Copy the code
Clone remote repository
After installing the Git client locally (this should all work), enter bash:
git clone root@[IP]:/opt/MyRepo
Copy the code
Here we use the Linux root user for cloning, so there is no permission problem, just need to enter the corresponding password can be directly cloned
Add a git_user user
Useradd git_user // Create a user (passwd sets the password) groupadd git_group // Create a group usermod-a-g git_group git_user // Add a user to a group git_group (-a: Append means no need to leave other groups.)Copy the code
The created non-root user needs to use the SSH KEY for access
If you are using Github, you will find a.shh folder in your C://user/[username]/ folder. Github is also a Git server, it can put the public key so that we can use the private key to access it, and our private server also needs to put the public key so that we can use the private key to access it. Let’s go ahead and use the public and private keys we already have.
- Open the id_rsa.pub file and copy its contents to /home/git_user/.ssh/authorized_keys on the Linux server. (If you do not have the id_rsa.pub file, you need to manually create the file.
- You can put multiple public keys into this file and paste it on another line. This allows multiple clients to access git servers with their own private key pairs.
Clone the remote repository as user git_user
Git [email protected]: / opt/MyRepoCopy the code
Note:
-
Add the public key to the.ssh/authorized_keys file in the server’s corresponding home directory (except root, SSH of root in the root/ directory.
-
From the top of the private server is only support SSH protocol. If you want to use HTTPS to interact with the server on software such as Little Turtle, SourceTree, etc., you can use Apache, Nginx, etc., to map the server repository through port 80 and then interact with it (such as Nginx: Configure nginx.conf file under nginx.conf. I haven’t tried whether Windows can use IIS to map the repository.
-
Nginx configuration static file server may refer to: blog.csdn.net/localhost01…