【Git】安装Git

事情的結果

我相信很多人都会觉得根本没有必要写这种东西吧!是的,如果没有什么了解的话,我也很可能会这样想。

这篇文章是关于如何用面向对象的方式编写文章的文章。
换句话说,如果想在任何环境中像在生产环境中那样使用它,我认为使用git是必不可少的,但是每次写文章都写同样的内容绝对是低效的。
然而,如果忽略了这一点,初学者会变得“不知所以然”,并且会降低对IT学习的动力。
如果因为这样而使动力下降,那么说做就做的做法很简单,但我认为培养人并非如此,而是“能够如何立足于对方视角教导对方”

因此,作为该对象的一个部分,我将保留这篇文章。

最好是从源代码安装Git。
如果使用yum安装,则会安装1.x版本。

[root@localhost ~]# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker

你可以在这里检查git的版本,
请确认最新的tar.gz的数字部分。

根据我撰写此文章时的信息,最新版本似乎是2.9.5。

[root@localhost ~]# wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
[root@localhost ~]# tar zxvf git-2.9.5.tar.gz

由于tar.gz文件被解压缩,因此需要移动到该目录。

[root@localhost ~]# cd git-2.9.5

编译。

[root@localhost ~]# make prefix=/usr/local all
[root@localhost ~]# make prefix=/usr/local install
[root@localhost git-2.9.5]# git --version
-bash: /usr/bin/git: そのようなファイルやディレクトリはありません

嗯?

只要我听到这句话,我就知道,你肯定没有通过。

[root@localhost git-2.9.5]# ./git --version
git version 2.9.5

当我查看时,发现在/usr/local/bin目录下有git,但是git的执行路径似乎是在/usr/bin中。
因此,我想将/usr/local/bin/git更改为/usr/bin/git。

[root@localhost ~]# cp /usr/local/bin/git /usr/bin/git
[root@localhost ~]# git --version
[root@localhost ~]# git version 2.9.5

可能是密码部分有点复杂,但总算完成了。

~~2020-03-19更新~~
顺便说一下,我很少使用github,所以很容易忘记(`・ω・´)ゞ

生成密钥对:私钥和公钥。

[root@localhost ~]# ssh-keygen -t rsa -b 4096 -C "your_email@hogefuga.com"

生成的id_rsa.pub

当要对GitHub进行克隆时,需事先指定密钥的位置。

[root@localhost ~]# vi ~/.ssh/config

对于公钥设定秘钥。

Host github
  Hostname github.com
  User git
  IdentityFile ~/.ssh/id_rsa

这种方法是使用密钥进行身份验证来克隆我的GitHub代码库的方式。现在让我们来克隆吧!