Detailed tutorial on building a private Git server on Linux

Detailed tutorial on building a private Git server on Linux

1. Server setup

The remote repository is actually no different from the local repository, it is purely for 24/7 operation and exchanging everyone's changes. GitHub is a remote repository that hosts open source code for free. However, for some commercial companies that regard source code as their life, they do not want to make the source code public, but are reluctant to pay protection fees to GitHub. In this case, they can only build a Git server themselves as a private warehouse.

To build a Git server, you need to prepare a machine running Linux. Here we use CentOS. The following are the installation steps:

1. Download git-2.22.0.tar.gz

https://Github.com/Git/Git/archive/v2.22.0.tar.gz

Use Xftp to put the installation package on the server

2. Install git service environment preparation

yum -y install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel gcc cc

1) Unzip, switch to the location where the git installation package is placed, and unzip it

tar –zxvf git-2.22.0.tar.gz

2) Switch directory

cd git-2.22.0

3) autoconf

4) ./configure

5) Compile (please wait patiently for one minute)

make

6) Installation

make install

3. Add users

adduser -r -c 'git version control' -d /home/git -m git

After this command is executed, the /home/git directory will be created as the home directory of the git user.

4. Set a password

passwd git

Enter your password twice

5. Switch to git user

su git

6. Create a git repository

mkdir repo1 Create a warehouse folder

git --bare init initializes the repository.

Note: If you do not use the "--bare" parameter, an error will be reported when submitting the master branch after initializing the repository. This is because git rejects the push operation by default, so you need to add the following code to .git/config:

[receive]

   denyCurrentBranch = ignore

It is recommended to use: git --bare init to initialize the repository.

2. Connect to the server

After the private git server is set up, you can connect and use it just like connecting to GitHub, but our git server is not configured with key login, so you need to enter a password every time you connect.

1. If you use TortoiseGit for synchronization, please refer to the following instructions.

Use the command to connect:

 $ git remote add origin ssh://[email protected]/home/git/first

This format seems different from the one we just used. It has a ssh:// prefix in front. Well, you can also write it like this:

 $ git remote add origin [email protected]:first

If you use TortoiseGit for synchronization, refer to the above instructions.

2. Git bash here cloning step

 git clone ssh://[email protected]/home/git/repo1

IP address 192.168.25.156

/home/git/repo1 is the path plus the warehouse name

Summarize

This is the end of this article about building a private Git server on Linux. For more relevant content about Linux private Git server, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to build a Git server in Linux
  • Detailed explanation of setting up Git server under Linux
  • Steps to build a Git server under Linux
  • Alibaba Cloud Linux-CentOS System-Detailed Explanation of Building Git Server
  • Detailed explanation of how to build a Git server under Linux

<<:  Detailed explanation of vue.js dynamic components

>>:  Exploration of three underlying mechanisms of React global state management

Recommend

How to install Nginx in a specified location in Centos system

How to install Nginx in a specified location in C...

Share 5 helpful CSS selectors to enrich your CSS experience

With a lot of CSS experience as a web designer, we...

Detailed explanation of query examples within subqueries in MySql

Where is my hometown when I look northwest? How m...

mysql backup script and keep it for 7 days

Script requirements: Back up the MySQL database e...

How to deploy Vue project using Docker image + nginx

1. Packaging Vue project Enter the following name...

VUE+Express+MongoDB front-end and back-end separation to realize a note wall

I plan to realize a series of sticky note walls. ...

In-depth understanding of JavaScript callback functions

Table of contents Preface Quick Review: JavaScrip...

Python writes output to csv operation

As shown below: def test_write(self): fields=[] f...

Implementing custom radio and check box functions with pure CSS

1. Achieve the effect 2 Knowledge Points 2.1 <...

Win10 + Ubuntu 16.04 dual system perfect installation tutorial [detailed]

Be sure to remember to back up your data, it is p...

Summary of commonly used multi-table modification statements in Mysql and Oracle

I saw this question in the SQL training question ...

Analysis of a MySQL deadlock scenario example

Preface Recently I encountered a deadlock problem...

How to add custom system services to CentOS7 systemd

systemd: The service systemctl script of CentOS 7...

How to solve the phantom read problem in MySQL

Table of contents Preface 1. What is phantom read...