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

Detailed explanation of docker nginx container startup and mounting to local

First, the structure inside the nginx container: ...

A method of making carousel images with CSS3

Slideshows are often seen on web pages. They have...

Detailed explanation of the use of Element el-button button component

1. Background Buttons are very commonly used, and...

Two ways to clear table data in MySQL and their differences

There are two ways to delete data in MySQL: Trunc...

Specific use of MySQL internal temporary tables

Table of contents UNION Table initialization Exec...

Two ways to visualize ClickHouse data using Apache Superset

Apache Superset is a powerful BI tool that provid...

Operate on two columns of data as new columns in sql

As shown below: select a1,a2,a1+a2 a,a1*a2 b,a1*1...

How to Find the Execution Time of a Command or Process in Linux

On Unix-like systems, you may know when a command...

Implementation of whack-a-mole game in JavaScript

This article shares the specific code for JavaScr...

CSS3 text animation effects

Effect html <div class="sp-container"...

Do you know all 24 methods of JavaScript loop traversal?

Table of contents Preface 1. Array traversal meth...

Understand the use of CSS3's all attribute

1. Compatibility As shown below: The compatibilit...

Detailed explanation of error handling examples in MySQL stored procedures

This article uses an example to describe the erro...

How to make spaces have the same width in IE and FF?

body{font-size:12px; font-family:"宋体";}...