Git与Github区别
Git是一个分布式版本控制系统,简单的说其就是一个软件或命令。
Github(https://www.github.com)是一个为用户提供Git服务的网站,简单说就是一个可以存放代码的地方。类似github的网站功能的有很多,如国内的https://gitee.com/。
github就是提供git远程仓库。
安装与配置
首先查看电脑是否安装Git,终端输入:
git
1.通过homebrew安装Git
brew install git
2.通过下载安装
下载地址:https://git-scm.com/downloads
GUI下载:https://tortoisegit.org/download/
配置git
设置username和email
git config --global user.name "phpdalao"
git config --global user.email "phpdalao@163.com"
通过终端命令创建ssh key
ssh-keygen -t rsa -C "phpdalao@163.com"
没有创建过的,会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。
终端查看.ssh/id_rsa.pub文件
用cat命令查看
cat .ssh/id_rsa.pub
登录GitHub(默认你已经注册了GitHub账号),添加ssh key,点击Settings,如图
添加key (title 随便写, key 写 刚才复制的key)
链接验证
ssh -T git@github.com
终端输出结果
bogon:~ ly$ ssh -T git@github.com
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi phpdalao! You've successfully authenticated, but GitHub does not provide shell access.
bogon:~ ly$
说明已经链接成功。
下一篇 写git提交项目到 github