如何在 RHEL 9 | Rocky Linux 9 上安装 Git ?
Git 是一个功能强大的版本控制系统,被开发人员广泛使用,用于管理源代码更改。
在本指南中,我们将向您介绍如何在 RHEL 9 或 Rocky Linux 9 上安装 Git 的过程。
通过 DNF 安装 Git
在 RHEL 9 或 Rocky Linux 9 上安装 Git 最简单的方法是使用默认的 DNF 包管理器。
- Update Your System
在安装任何新软件之前,最好将系统包更新到最新版本
$ sudo dnf update -y
- Install Git
现在,使用以下 dnf 命令安装 Git
$ sudo dnf install git -y
- Verify the Installation
要检查 Git 是否成功安装,请使用以下命令验证版本
$ git --version
源代码安装 Git
从源代码安装 Git 是另一种获取最新版本的方法版本或特定版本的 Git。这个方法是有用的,如果 通过包管理器提供的版本已过时。
- Install Development tools
在从源代码构建 Git 之前,需要使用以下 dnf 命令安装开发工具。
$ sudo dnf groupinstall 'Development Tools' -y
接下来,使用下面的命令安装其他必需的依赖项
$ sudo dnf install wget curl-devel perl-ExtUtils-MakeMaker gettext openssl-devel zlib-devel curl-devel expat-devel -y
- Download the Latest Git Source Code
访问 “https://mirrors.edge.kernel.org/pub/software/scm/git/” 下载最新的源代码
或者,您可以使用下面的命令直接下载它
$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.47.0.tar.gz
3) Extract the Downloaded Archive
使用 tar 命令提取 tar 文件
$ tar -xf git-2.47.0.tar.gz
$ cd git-2.47.0
- Compile and Install Git
使用以下命令编译 Git 源代码
$ make configure
$ ./configure --prefix=/usr
$ sudo make all
$ sudo make install
- Verify the Installation
安装完成后,验证安装的 Git 版本
$ git --version
配置 Git
在安装 Git 之后,设置您的用户名和电子邮件是必要的,此信息将与您的提交相关联。
- Set Your Username
$ git config --global user.name "Pradeep Kumar"
- Set Your Email Address
$ git config --global user.email "info@linuxtechi.com"
- Verify the Configuration
$ git config --list
我的开源项目
评论已关闭