git安装与配置

安装

解压

[root@iZbp14eey5dlgt99xx7qptZ data]# pwd
/data
[root@iZbp14eey5dlgt99xx7qptZ data]# tar -zxvf git-2.27.0.tar.gz 

安装依赖包

//make: curl-config: Command not found
//    CC fuzz-commit-graph.o
//In file included from commit-graph.h:4,
//                 from fuzz-commit-graph.c:1:
//git-compat-util.h:297:10: fatal error: openssl/ssl.h: No such file or directory
// #include <openssl/ssl.h>
//          ^~~~~~~~~~~~~~~
//compilation terminated.
//make: *** [Makefile:2391: fuzz-commit-graph.o] Error 1
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

卸载旧版本git

//安装依赖包时,系统自动安装了git
yum -y remove git

编译

[root@iZbp14eey5dlgt99xx7qptZ git-2.27.0]# pwd
/data/git-2.27.0
[root@iZbp14eey5dlgt99xx7qptZ git-2.27.0]# make prefix=/usr/local/git all

安装到指定路径

make prefix=/usr/local/git install

配置环境变量

vi /etc/profile //底部加 export PATH=$PATH:/usr/local/git/bin
source /etc/profile //刷新环境变量

测试

[root@iZbp14eey5dlgt99xx7qptZ /]# git --version

配置

用户名、邮箱

[root@iZbp14eey5dlgt99xx7qptZ /]# git config --global user.name "puhome"
[root@iZbp14eey5dlgt99xx7qptZ /]# git config --global user.email "363140622@qq.com"

git存储目录

[root@iZbp14eey5dlgt99xx7qptZ /]# mkdir myhome
[root@iZbp14eey5dlgt99xx7qptZ /]# cd myhome/
[root@iZbp14eey5dlgt99xx7qptZ myhome]# mkdir mygit
[root@iZbp14eey5dlgt99xx7qptZ myhome]# ls
mygit
[root@iZbp14eey5dlgt99xx7qptZ myhome]# cd mygit
[root@iZbp14eey5dlgt99xx7qptZ mygit]# pwd
/myhome/mygit

初始化git

[root@iZbp14eey5dlgt99xx7qptZ mygit]# pwd
/myhome/mygit
[root@iZbp14eey5dlgt99xx7qptZ mygit]# git init
Initialized empty Git repository in /myhome/mygit/.git/

生成ssh-key 密钥对,包含:公钥、私钥

[root@iZbp14eey5dlgt99xx7qptZ mygit]# ssh-keygen -t rsa -C "3***2@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): Z***
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Passphrases do not match.  Try again.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Passphrases do not match.  Try again.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in Z***.
Your public key has been saved in Z***.pub.
The key fingerprint is:
SHA256:r3+5***b0XUMnjlRSTNoKwSc 3***2@qq.com
The key's randomart image is:
+---[RSA 3072]----+
|         .. .=+  |
|          E.o++ .|
|          .+.+.o |
|        .  ...+  |
|       .S..... . |
|        ...+.o   |
|         .= B.* +|
|        .o Bo=.B+|
|       .o.o.++=**|
+----[SHA256]-----+

将私钥id_rsa添加到ssh代理中

[root@iZbp14eey5dlgt99xx7qptZ mygit]# pwd
/myhome/mygit
[root@iZbp14eey5dlgt99xx7qptZ mygit]# ssh-add puhomeid
Could not open a connection to your authentication agent.
[root@iZbp14eey5dlgt99xx7qptZ mygit]# eval $(ssh-agent -s)
Agent pid 44138
[root@iZbp14eey5dlgt99xx7qptZ mygit]# ssh-add puhomeid
Enter passphrase for puhomeid: 
Bad passphrase, try again for puhomeid: 
Identity added: puhomeid (36***2@qq.com)

将公钥id_rsa.pub添加到github仓库中

[root@iZbp14eey5dlgt99xx7qptZ mygit]# pwd
/myhome/mygit
[root@iZbp14eey5dlgt99xx7qptZ mygit]# vim puhomeid.pub  //复制公钥内容
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值