工具-Git与GitHub-GitHub使用(99.5.3)

@

1.在github中添加公钥

首次使用git必须配置邮箱(邮箱和github一致)

git config --global user.name "xxx"
git config --global user.email xxxxx@example.com

在linux命令行或者win的git-bash中输入

ssh-keygen -t rsa -C "邮箱地址"

进入主目录下的.ssh文件,使用文本工具查看公钥复制此内容到github的设置中
公钥为id_rsa.pub
私钥为id_rsa
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190831115517858.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI2NjI0MzI5,size_16,color_FFFFFF,t_70)

2.克隆项目

切换到要使用git的目录,使用ssh克隆

git clone git@github.com:BOTHSAVAGE/Test.git

![在这里插入图片描述]( https://img-blog.csdnimg.cn/2019083111570460.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI2NjI0MzI5,size_16,color_FFFFFF,t_70)

3.在本地工作区新建分支,修改文件并提交

git checkout -b smart
git add .
git commit -m "first_commit"

4.推送到远程仓库

git push origin 分支名称
例:
git push origin smart

将本地分支跟踪远程分支

git branch --set-upstream-to=origin/远程分支名称 本地分支名称
例:
git branch --set-upstream-to=origin/smart smart

5.从远程分支上拉取代码

git pull orgin 分支名称
例:
git pull orgin smart

![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190831120250350.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI2NjI0MzI5,size_16,color_FFFFFF,t_70)

关于作者

个人博客网站
个人GitHub地址
个人公众号:
![在这里插入图片描述]( https://imgconvert.csdnimg.cn/aHR0cDovL21tYml6LnFwaWMuY24vbW1iaXpfcG5nL2Y3UEk3eWZpYTNTZUI1MkFDZ1NKdE4yNGljY3VOMmhYbTBsZG1IUHhFREU2SmNCSEkydEFyeHVjMnppYjNxQnJ4bkVtb2lidGJLSG5zU3ZWNjRQblVYUzRpY0EvMA?x-oss-process=image/format ,png)

posted @ 2019-08-31 12:06  BothSavage  阅读(143)  评论(0)    收藏  举报