CentOS 6 安装 Git

本文详细介绍了如何在CentOS系统上安装Git,并进行基本的配置,包括设置用户名和邮箱、创建SSH密钥等。此外还提供了从GitHub克隆仓库、编辑文件、提交更改的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 安装 Git:

# yum update    # 1.更新系统
# yum install curl-devel expat-devel gettext-devel openssl-devel gcc perl-ExtUtils-MakeMaker    # 2.安装依赖包
# 3.下载最新的 Git 源码并解压缩: https://www.kernel.org/pub/software/scm/git/
# tar zxvf git-2.9.4.tar.gz
# cd git-2.9.4
# make prefix=/usr/local/git all    # 4.编译到指定目录
# make prefix=/usr/local/git install    # 5.安装到指定目录
# whereis git    # 6.查看 git 所在的路径
# vim /etc/profile        # 7.把 git 路径放到环境变量中
export PATH=/usr/local/git/bin:$PATH    
# source /etc/profile
# git --version    # 8.查看 git 版本

2.设置 Git:

$ pwd
/home/centos
$ git config --global user.name "Philly008"    # 设置用户名和 email
$ git config --global user.email "liuup66@163.com"
$ ls -a | grep .gitconfig    # 设置完成后会生成 .gitconfig 文件
$ ssh-keygen -t rsa -C "liuup66@163.com"    # 创建 SSH Key,默认路径即可(一般是 ~/.ssh)
$ cat ~/.ssh/id_rsa.pub    # 复制此文件内容到 Github>settings>SSH Key>Add SSH key 里面
$ ssh -T git@github.com    # 测试链接是否成功

3.为 Github 上的 Repository 提交修改:

$ git clone https://github.com/Philly008/autotest.git
$ cd ./autotest
$ vim README.md
$ git status
$ git add README.md
$ git commit -m "Edit by Centos 20170601"
$ git remote add origin https://github.com/Philly008/autotest.git
此时会报错:remote origin already exists.
$ git remote rm origin
$ git remote add origin https://github.com/Philly008/autotest.git
$ git push -u origin master    # 提交完成后,查看 Github 上的 Repository 的更改。

转载于:https://www.cnblogs.com/liuliu3/p/6931436.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值