github的使用流程记录

参考

https://blog.csdn.net/north1989/article/details/53471439
http://www.runoob.com/w3cnote/git-guide.html

本地环境

Ubuntu16.04 终端

配置Git

首先在本地创建 ssh key

$ ssh-keygen -t rsa -C "[email protected]"

github的使用流程记录_第1张图片

后面的[email protected]改为你在github上注册的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。

github的使用流程记录_第2张图片

回到github上,进入 Account Settings(账户配置),左边选择SSH Keys,Add SSH Key,title随便填,粘贴在你电脑上生成的key。
github的使用流程记录_第3张图片

为了验证是否成功,在git bash下输入:

$ ssh -T [email protected]

可能会出现:agent refused operation Permission denied (publickey) Error 的问题

参考:https://segmentfault.com/a/1190000008733238
https://www.jianshu.com/p/3d3569674ea4 解决

在这里插入图片描述

接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。

$ git config --global user.name "your name"
$ git config --global user.email "[email protected]"

在这里插入图片描述

接下来,将已有的项目添加到 github
首先先从 github 上创建一个空的仓库,并且复制链接地址
github的使用流程记录_第4张图片

在已经初始化本地仓库并且提交内容到本地的基础上,

git remote add origin 远程仓库地址
git push -u origin master

你可能感兴趣的:(Git)