mac安装最新版本的git

时间:2021-01-27 10:44:56

文章转载自我的个人博客 http://www.iwangzheng.com/

1.下载一个安装包哦

在mac下安装git,首先下载一个git安装包,这里我选的是git-1.9.3.tar ,

因为这是比较新的一个版本,

网址是  https://www.kernel.org/pub/software/scm/git/

2. 在一个你喜欢的文件夹里解压一下安装包

打开terminal终端,进入安装包所在的文件夹之后执行以下的解压命令

$ tar -xf git-1.9.3.tar

3. 编译安装的命令如下

$ cd git-1.9.3

$  ./configure –prefix=/usr/local

$  make

$  sudo make install

4.查看一下git的安装路径

$which git

这里会得到路径/usr/local/bin/git

祝贺你已经安装完啦。以下来配置ssh连接吧

1.生成ssh的key

$ ssh-keygen -t rsa -C  aaaa@163.com  (后面的是git上注册的邮件哦)

$ vim id_rsa.pub (用vim命令打开文件可以复制一下啦)

不明白的同学可以看下面完的完整操作记录如下哦

angeladeMacBook-Air:.ssh angela$ ssh-keygen -t rsa -C aaaaa@163.com

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/angela/.ssh/id_rsa): key

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

angeladeMacBook-Air:.ssh angela$ ssh-keygen -t rsa -C aaaaa@163.com

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/angela/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /Users/angela/.ssh/id_rsa.

Your public key has been saved in /Users/angela/.ssh/id_rsa.pub.

The key fingerprint is:

0e:70:c0:67:4b:08:15:b3:37:d9:b9:9a aaaaa@163.com

The key’s randomart image is:

+–[ RSA 2048]—-+

|  .+=o           |

|    o++o         |

|    o+=..        |

|     +.. .       |

|        o=..     |

|        E+o      |

+—————–+

2.登录github设置一下账户里的ssh key

在登录后直接点击右上方的工具按钮,也就是页面最上方从右边数第二个按钮(Account settings)

或者直接点击下面的网址

https://github.com/settings/ssh

进入Account setting之后,页面左侧有一列菜单,里面有一项是 SSH keys,点击后页面右侧会有add SSH keys的选项,点击后就可以把之前vim id_rsa.pub之后的内容粘贴过来啦。

3 已经配好啦,现在就可以回终端里测试一下啦。

angeladeMacBook-Air:.ssh angela$ ssh git@github.com

The authenticity of host ‘github.com (192.30.xxx .xxx)’ can’t be established.

RSA key fingerprint is 16:27:ac::63:1b:56:4d:eb:df:a68.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘github.com,192.30.xxx.xxx’ (RSA) to the list of known hosts.

PTY allocation request failed on channel 0

Hi aaaaaa! You’ve successfully authenticated, but GitHub does not provide shell access.

Connection to github.com closed.

完成啦,现在github和本地的git就可以顺利的连接啦,本地的代码就可以上传git仓库啦。

--------------------------------------------------------------------------------------------------------------------

欢迎来到我的博客, 本人乃互联网行业一枚小小的螺丝钉—非典型程序员妹子.

留下微信地址,方便大家和我联系

mac安装最新版本的git