Git is an open source distributed version control system used to manage code changes. It enables collaboration among multiple developers and can track the history of changes to the code base. Git is a very important tool for developers using Linux systems. This article will introduce the commands to install Git in Linux systems.
You can use the apt-get command to install Git on Ubuntu and Debian systems. Enter the following command in the terminal:
$ sudo apt-get update $ sudo apt-get install git
To install Git on CentOS and Fedora systems, you can use the yum command. Enter the following command in the terminal:
$ sudo yum install git
If you want to install Git from source, you can perform the following steps:
3.1 Download Git source code
You can download the latest source code file from Git’s official website (https://git-scm.com/download).
3.2 Unzip the file
Extract the downloaded file and enter the unzipped folder.
$ tar -zxf git-2.32.0.tar.gz $ cd git-2.32.0/
3.3 Check dependencies
Before installing Git, please make sure that your system has the following dependencies installed: curl, zlib, expat and gettext.
On Ubuntu and Debian systems, you can use the following command to install dependencies:
$ sudo apt-get install curl zlib1g-dev libexpat1-dev gettext
On CentOS and Fedora systems, you can use the following command:
$ sudo yum install curl-devel zlib-devel expat-devel gettext-devel openssl-devel
3.4 Compile and install Git
Enter the following command in the terminal to start compiling and installing Git:
$ make prefix=/usr/local all $ sudo make prefix=/usr/local install
After the installation is complete, you can use the following command Check the version number of Git:
$ git --version
If the version number you installed is different from the version number you expected, please make sure you have performed the above steps correctly.
Summary
This article introduces three ways to install Git commands on Linux systems, including using the package manager to install, compiling and installing from source code, and checking the Git version number. Choose the way that suits you to install Git, allowing you to better manage your code base.
The above is the detailed content of What is the command to install Git in Linux system. For more information, please follow other related articles on the PHP Chinese website!