動態

詳情 返回 返回

如何在 RHEL 9 | Rocky Linux 9 上安裝 Git ? - 動態 詳情

install git on rhel9 | rocky linux 9

Git 是一個功能強大的版本控制系統,被開發人員廣泛使用,用於管理源代碼更改。

在本指南中,我們將向您介紹如何在 RHEL 9 或 Rocky Linux 9 上安裝 Git 的過程。

通過 DNF 安裝 Git

在 RHEL 9 或 Rocky Linux 9 上安裝 Git 最簡單的方法是使用默認的 DNF 包管理器。

1) Update Your System

在安裝任何新軟件之前,最好將系統包更新到最新版本

$ sudo dnf update -y

2) Install Git

現在,使用以下 dnf 命令安裝 Git

$ sudo dnf install git -y

Install Git on RHEL 9

3) Verify the Installation

要檢查 Git 是否成功安裝,請使用以下命令驗證版本

$ git --version

Git Version After Installing From Package Manager

源代碼安裝 Git

從源代碼安裝 Git 是另一種獲取最新版本的方法版本或特定版本的 Git。這個方法是有用的,如果
通過包管理器提供的版本已過時。

1) Install Development tools

在從源代碼構建 Git 之前,需要使用以下 dnf 命令安裝開發工具。

$ sudo dnf groupinstall 'Development Tools'  -y

Install Development Tools On RHEL 9 Or Rocky Linux 9

接下來,使用下面的命令安裝其他必需的依賴項

$ sudo dnf install wget curl-devel perl-ExtUtils-MakeMaker gettext openssl-devel zlib-devel curl-devel expat-devel -y

2) 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

Download Latest Git from Command Line
3) Extract the Downloaded Archive

使用 tar 命令提取 tar 文件

$ tar -xf git-2.47.0.tar.gz
$ cd git-2.47.0

4) Compile and Install Git

使用以下命令編譯 Git 源代碼

$ make configure
$ ./configure --prefix=/usr

Configure Prefix for Git Compile

$ sudo make all

Git Compile Make All RHEL 9

$ sudo make install

Install Git On RHEL 9 From Source

5) Verify the Installation

安裝完成後,驗證安裝的 Git 版本

$ git --version

Git Version Build From Source RHEL 9

配置 Git

在安裝 Git 之後,設置您的用户名和電子郵件是必要的,此信息將與您的提交相關聯。

1) Set Your Username

$ git config --global user.name "Pradeep Kumar"

2) Set Your Email Address

$ git config --global user.email "info@linuxtechi.com"

Configure Git on RHEL 9

3) Verify the Configuration

$ git config --list

Git Config List RHEL 9

我的開源項目

酷瓜雲課堂-開源知識付費解決方案

user avatar caigaobadoudetangyuan 頭像 shoushoudeqie 頭像 yansudeshanyang 頭像
點贊 3 用戶, 點贊了這篇動態!
點贊

Add a new 評論

Some HTML is okay.