How to set up and configure a Git server
The content of this article is to introduce how to build and configure a Git server. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Install Git
Install dependencies
yum install curl-devel expat-devel gcc gcc-c++ yum install perl perl-devel gettext-devel openssl-devel zlib-devel
Compile and install Git
# 下载Git wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz # 解压 tar zxvf git-2.9.5.tar.gz cd git-2.9.5 # 预编译、编译、安装 make configure ./configure --prefix=/usr/local/git make && make install
Configure environment variables
vim /etc/profile export PATH="$PATH:/usr/local/git/bin" source /etc/profile # 使修改立即生效
Server configuration
Create Git user
Create a git user group and user to run the git service:
groupadd git useradd git -g git
Create certificate login
Collect the public keys of all users who need to log in. The public keys are located in the id_rsa.pub file. Put our public keys Import the keys into the /home/git/.ssh/authorized_keys file, one per line.
If there is no such file, you need to create it:
cd /home/git/ mkdir .ssh chmod 755 .ssh touch .ssh/authorized_keys chmod 644 .ssh/authorized_keys
So how to generate the public key on your own client?
If it is a windows computer, you can open the Git client. If If you are using a Mac, you can open the terminal that comes with the Mac and execute the following command
ssh-keygen -t rsa -C "你的邮箱" //例如ssh-keygen -t rsa -C "xxx@gmail.com"
After the above command is executed successfully, obtain the public key through the following command
cat ~/.ssh/id_rsa.pub
The terminal tool will print out the public key and copy it Public key, fill in the authorized_keys of the server
Initialize Git warehouse
First we select a directory as the Git warehouse, assuming it is/ home/gitrepo/blog, enter the command in the /home/gitrepo directory:
cd /home mkdir gitrepo chown git:git gitrepo/ cd gitrepo git init --bare blog.git # 执行完会有如下提示 Initialized empty Git repository in /home/gitrepo/blog.git/
The above command Git creates an empty warehouse. Git warehouses on the server usually end with .git. Then, change the user who owns the warehouse to git:
chown -R git:git blog.git
Clone the warehouse
git clone git@192.168.111.129:/home/gitrepo/blog.git # 或 git clone ssh://git@192.168.111.129:22/home/gitrepo/blog.git //版本库地址,支持ssh协议
Note: If it prompts git-upload here -pack: command not found
, you can use the
command on the version server
ln -s /usr/local/git/bin/git-upload-pack /bin/
and then re-execute git clone
After successfully pulling the project, you can edit and submit it locally
touch index.php git add index.php git commit -a -m'提交index.php文件' git push origin master //推送到公共服务器
When executing the push command, if git-receive-pack: command not found
error is reported, create a soft connection again
ln -s /usr/local/git/bin/git-receive-pack /bin/
Execute the push command again Can.
The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !
The above is the detailed content of How to set up and configure a Git server. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions and supports local operations; GitHub provides online collaboration tools such as Issue tracking and PullRequest.

Git and GitHub are not the same thing. Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions, and GitHub provides an online collaboration environment.

GitHub is not difficult to learn. 1) Master the basic knowledge: GitHub is a Git-based version control system that helps track code changes and collaborative development. 2) Understand core functions: Version control records each submission, supporting local work and remote synchronization. 3) Learn how to use: from creating a repository to push commits, to using branches and pull requests. 4) Solve common problems: such as merge conflicts and forgetting to add files. 5) Optimization practice: Use meaningful submission messages, clean up branches, and manage tasks using the project board. Through practice and community communication, GitHub’s learning curve is not steep.

On your resume, you should choose to write Git or GitHub based on your position requirements and personal experience. 1. If the position requires Git skills, highlight Git. 2. If the position values community participation, show GitHub. 3. Make sure to describe the usage experience and project cases in detail and end with a complete sentence.

Starting from Git is more suitable for a deep understanding of version control principles, and starting from GitHub is more suitable for focusing on collaboration and code hosting. 1.Git is a distributed version control system that helps manage code version history. 2. GitHub is an online platform based on Git, providing code hosting and collaboration capabilities.

Microsoft does not own Git, but owns GitHub. 1.Git is a distributed version control system created by Linus Torvaz in 2005. 2. GitHub is an online code hosting platform based on Git. It was founded in 2008 and acquired by Microsoft in 2018.

Git is an open source distributed version control system that helps developers track file changes, work together and manage code versions. Its core functions include: 1) record code modifications, 2) fallback to previous versions, 3) collaborative development, and 4) create and manage branches for parallel development.

The reason for using GitHub to manage HTML projects is that it provides a platform for version control, collaborative development and presentation of works. The specific steps include: 1. Create and initialize the Git repository, 2. Add and submit HTML files, 3. Push to GitHub, 4. Use GitHubPages to deploy web pages, 5. Use GitHubActions to automate building and deployment. In addition, GitHub also supports code review, Issue and PullRequest features to help optimize and collaborate on HTML projects.
