centos7安装git并配置

223 阅读1分钟
开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第1天,[点击查看活动详情](https://juejin.cn/post/7167294154827890702 "https://juejin.cn/post/7167294154827890702")

1、首先去下载git安装包:github.com/git/git/tag…

image.png 2、上传至服务器并解压

解压命令:tar -xzvf git-2.38.1.tar.gz

3、安装

  1. cd git-2.38.1/
  2. make configure
  3. ./configure --prefix=/usr/local/git
  4. make profix=/usr/local/git
  5. make install

4、配置环境变量

  1. vim /etc/profile
  2. export PATH=$PATH:/usr/local/git/bin

image.png

5、 刷新配置文件并验证

  1. source /etc/profile
  2. git --version

image.png

6、配置git账户和密码

  1. git config --global user.name "Your Name"
  2. git config --global user.email "email@example.com"
  3. git config --list

7、生成Git和私钥

使用命令生成公钥和私钥:ssh-keygen -t rsa -C "email@example.com"

image.png

8、配置gitee 或者 github

如:github,首先登录github账号,点击右上角头像,找到setting-->SSH AND GPK keys

image.png

接着使用cat /root/.ssh/id_rsa.pub 查看并复制

image.png 保存成功以后去使用验证:

image.png