MAC 下 Git的安装与基本配置 博客分类: Git安装 git mac 安装配置
程序员文章站
2024-03-15 16:45:00
...
- 下载git版本源码:(前提是安装了xcode)
http://kernel.org/pub/software/scm/git/
- 解压下载在安装包:
tar xjvf git-1.8.4
- 编译 cd git-1.8.4
./configure --prefix=/usr/local make
- 安装
sudo make install
- 检查安装git的版本
git --version
- 查看git的安装路径
which git
- 设置SSH
//检查SSH key cd ~/.ssh //备份已有的key mkdir key_backup mv id_rsa*key_backup
- 生成SSH key
ssh-keygen -t rsa -C 1255892351@qq.com //备注:后面的邮箱为注册github账号的邮箱
运行之后,生成SSH keyGenerating public/private rsa key pair. Enter file in which to save the key (/Users/chenyue123/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in yes. Your public key has been saved in id_rsa.pub. The key fingerprint is: fb:c4:b0:e0:47:fd:be:e0:fb:ea:73:ef:a8:29:d5:22 1255892351@qq.com The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | . | | . S .. | | . oE=o.. | | . +o+.. | | ..+.+.. | | oOB=+o | +-----------------+
- 将SSH key添加到GitHub
登录到GitHub页面,找到
Account Settings->SSH Public Keys->Add another key
将生成的key(id_rsa.pub文件)内容copy到输入框中,save。 - 测试链接
ssh git@github.com
运行结果显示The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes PTY allocation request failed on channel 0 Hi chenyue123! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
- 设置个人信息
//设置github默认用户名 git config --global user.name "chenyue123" //设置github默认用户邮箱 git config --global user.email "1255892351@qq.com"
- 开启终端输入git命令时显示颜色
git config --global color.ui true
- 查看git默认的用户名和邮箱
//查看git的默认用户名 git config user.name //查看git的默认邮箱 git config user.email
//打印结果分别为 //用户名 chenyue123 //邮箱 1255892351@qq.com
推荐阅读