Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a private Git server on linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

The editor of this article introduces in detail "how to build a private Git server on linux". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to build a private Git server on linux" can help you solve your doubts.

1. Server building

The remote warehouse is actually no different from the local warehouse, purely for the purpose of booting 7x24 hours and exchanging changes. Github is a remote repository that hosts open source code for free. But for some commercial companies that see source code such as life, they do not want to release the source code and are reluctant to pay github protection fees, so they can only build their own git server to use as a private warehouse.

To build a git server, you need to prepare a machine running linux, and here we use centos. The following are the installation steps:

1. Download git-2.22.0.tar.gz

Use xftp to put the installation package on the server

2. Prepare the environment for installing git services

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

1) decompress, switch the location of the git installation package, and decompress

Tar-zxvf git-2.22.0.tar.gz

2) switch directories

Cd git-2.22.0

3) autoconf

4). / configure

5) compile (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 is created as the home directory of the git user.

4. Set the password

Passwd git

Enter the password twice

5. Switch to git user

Su git

6. Create a git repository

Mkdir repo1 creates a warehouse folder

Git-- bare init initializes the repository.

Note: if you do not use the "--bare" parameter, you will make an error submitting the master branch after initializing the warehouse. This is because git rejects the push operation by default, which requires the following code to be added to .git / config:

[receive] denycurrentbranch = ignore

It is recommended to initialize the warehouse using git-- bare init.

two。 Connect to the server

After the private git server is built, it can be used as a connection to github, but our git server does not have a key login configured, so you need to enter a password for each connection.

1. Refer to the following usage for using tortoisegit synchronization.

Use the command to connect:

$git remote add origin ssh://git@192.168.25.156/home/git/first

This form seems to be different from the one just used, which is preceded by a ssh:// prefix. Well, you can also write this:

$git remote add origin git@192.168.25.156:first

If you use tortoisegit synchronization, refer to the above usage.

2.git bash here cloning step

Git clone ssh://git@192.168.25.156/home/git/repo1

Ip address 192.168.25.156

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

After reading this, the article "how to build a private Git server on linux" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report