JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM > Git >

Git installation and establishment of local warehouse service

Author:JIYIK Last Updated:2025/04/05 Views:

Git is a distributed version control system: the client does not only extract the latest version of the file snapshot, but also completely mirrors the original code repository. It has the following advantages:

a. Since every extraction operation by anyone is actually a complete backup of the code repository, almost all operations can be performed locally, the speed is quite fast, and the operation will not be affected when the network is disconnected. You can submit updates frequently and upload them to the remote mirror repository when the network is available .

b. The documentation is very detailed, and the command line prompts are also very detailed, making it relatively easy to use, and many of the settings and operations are very similar to Linux operations (no wonder it was created by the father of Linux).

c. Git's branch model is quite lightweight and is known as a "must-have skill".

Let's take a look at how to install git on a Linux system.

Git Installation

First download git-2.7.3.tar.gz

$ wget https://www.kernel.org/pub/software/scm/git/git-2.7.3.tar.gz

Then unzip the source code package and enter the source code directory to install it.

$ tar –zxvf git-2.7.3.tar.gz
$ ./configure
$ make && make install

If everything goes well, git can be installed successfully after the above steps.

It should be noted here that installing git requires the support of gcc and zlib. So before installing git, we need to make sure that our system has these two tools installed.

Git creates a local repository service

First, we clone a project on GitHub to our local machine.

$ git clone https://github.com/onmpw/phpApp.git

Then we create a new repository

$ git clone –bare phpApp /opt/phpApp.git
Cloning into bare repository 'phpApp.git'...
done.

Now that we have a simple repository, there should be a copy of the git directory in the phpApp.git directory.

Next we put the newly created warehouse on the server.

$ scp –r /opt/phpApp.git root@192.168.5.101:/opt/phpApp.git

At this point, if the user connects to this server (5.101) via ssh and has read permissions on /opt, then the repository can be cloned via git.

$ git clone root@192.168.5.101:/opt/phpApp.git

In addition, if a user logs in to the server via ssh and has write permissions to the /opt/phpApp.git directory, then he will automatically have push permissions.

Log in to the server via ssh, go to the project directory and run the git init command, and add the --shared option, then Git will automatically change the group permissions of the repository directory to writable.

$ ssh root@192.168.5.101
$ cd /opt/phpApp.git
$ git init –shared –bare

At this point we can clone our own warehouse through ssh and push the project.

Of course, usually we need to use the git protocol to implement our warehouse service. It is actually very simple to use the git protocol, just need to use a git daemon (similar to the opening of mysqld and other services).

$ git daemon –reuseaddr –base-path=/opt/ /opt/

The process listens on port 9418, so if there is a firewall before our service, we need to set the firewall to allow communication on port 9418. --reuseaddr allows the server to restart without waiting for the old connection to time out. The --base-path option allows users to clone projects without fully specifying the path. The path at the end tells the Git daemon where to find the repository to export.

Next, we go to the project warehouse directory phpApp.git and create a file named git-daemon-export-ok in each warehouse to achieve this.

$ cd /opt/phpApp.git
$ touch git-daemon-export-ok

This file will allow Git to provide unauthorized access to your project.

Then we can clone the project again through the git command, but the address used is the git protocol.

$ git clone git://192.168.5.101/phpApp.git

It should be noted here that because we set the mapped directory to /opt above, git://192.168.5.101 is mapped to the directory /opt. Therefore, when we write the address, we directly follow it with the project repository name, and /opt is no longer needed.

Well, the above is the method of installing git and creating a repository introduced in this section. I hope this article will be helpful to you.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

Finding the installed version of Pandas

Publish Date:2025/04/12 Views:190 Category:Python

Pandas is one of the commonly used Python libraries for data analysis, and Pandas versions need to be updated regularly. Therefore, other Pandas requirements are incompatible. Let's look at ways to determine the Pandas version and dependenc

Issues to note when installing Apache on Linux

Publish Date:2025/04/08 Views:78 Category:OPERATING SYSTEM

As the most commonly used web server, Apache can be used in most computer operating systems. As a free and open source Unix-like operating system, Linux and Apache are a golden pair. This article will introduce the installation and use of A

Apache2.4 installation and precautions under Windows7

Publish Date:2025/04/08 Views:125 Category:OPERATING SYSTEM

To install apache2.4 in Windows 7, we first need to download the apache2.4 installation program. Here we download the software from the apache official website http://httpd.apache.org/download.cgi . First, let's see how to download apache2.

How to Install Nginx on Ubuntu 20.04?

Publish Date:2025/04/07 Views:157 Category:OPERATING SYSTEM

Nginx is one of the most popular web servers in the world, responsible for hosting some of the largest and most trafficked sites on the Internet. It is a lightweight application software that can be used as a web server or a reverse proxy.

Detailed introduction to installing Gradle on Windows

Publish Date:2025/04/07 Views:138 Category:OPERATING SYSTEM

Gradle is a Java-based tool, so it requires Java 8 or higher to be running on your machine. Before installing Gradle, make sure you have Java SDK 8 or higher installed. It runs on all major operating systems. We don't need to install groovy

Linux: How to install htop on Ubuntu and Mint

Publish Date:2025/04/06 Views:129 Category:OPERATING SYSTEM

While top the htop utility provides us with basic information about the processes running on our Linux system, the htop utility goes a step further and provides us with more information about the processes and also allows for several operat

How to install GrayLog on centos

Publish Date:2025/04/06 Views:122 Category:OPERATING SYSTEM

Installing Graylog on CentOS requires the following steps: 1. Add EPEL and MongoDB repositories: sudo yum install epel-release -y sudo rpm -Uvh https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.4-1.el7

How to install Elasticsearch on CentOS

Publish Date:2025/04/06 Views:157 Category:OPERATING SYSTEM

Elasticsearch is an open source search engine developed based on Java, so you need to install the Java runtime environment to run it properly. Specifically, Elasticsearch is a distributed search engine built on Apache Lucene. It uses Java t

How to Install GCC Compiler on Ubuntu 18.04

Publish Date:2025/04/06 Views:165 Category:OPERATING SYSTEM

GCC It is the abbreviation of GNU Compiler Collection , which is applicable to different programming languages ​​such as R, C, C++, Objective-C, Fortran, Ada, Go, D, etc. We can apt install the compiler on Ubuntu using the command line

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial