---
title: 安装Git
description: "1. 下载Git v2.21.0的源码。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengbds/testguide/tstg/kunpengbdses_11_0006.html
sourcePath: /source/zh/kunpengbds/testguide/tstg/kunpengbdses_11_0006.html
indexId: 9f55a1abfa838a24a51d0f044039252b4caaeb07d4c6e5e6446c4f5bc7a5b5b462
---
# 安装Git

1. 下载Git v2.21.0的源码。
  1 wget https://github.com/git/git/archive/v2.21.0.tar.gz

2. 解压v2.21.0.tar.gz。
  1 tar -zxvf v2.21.0.tar.gz

3. 进入Git源码目录。
  1 cd git-2.21.0/

4. 查询是否已经安装过Git，如果没有安装过可直接跳过此步骤，如果已经安装过Git，需先卸载原来的Git。
  1 git

5. 可选：卸载原有Git。
  1 yum remove git

6. 编译Git。
  1 2 3 4 autoconf ./configure --prefix=/usr/local/git make make install

7. 配置Git环境变量。
  1 echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile

8. 使修改的环境变量生效。
  1 source /etc/profile

9. 查询Git版本。
  1 git --version

  如下所示即为Git安装成功。
