git配置SSH Key,上传本地代码至github

git配置全局的name和email

git config --global user.name "name"  
  
git config --global user.email "email"

name和email是注册github的昵称和邮箱。git

git配置SSH Key

一、 打开git bash.exegithub

二、检查是否已经有SSH Key$ cd ~/.sshshell

三、生成SSH Keyssh-keygen -t rsa -C "youremail"bash

第一次生成的话,直接一路回车,不须要输入密码。不是第一次生成的话,会提示 overwrite (y/n)? 问你是否覆盖旧的 SSH Key ,直接填 y ,而后一直回车就好了,最后获得了两个文件:id_rsa和id_rsa.pub。
ssh

四、记事本打开/C/Users/Administrator/.ssh/下id_rsa.pub文件,复制该段信息;登陆github帐户,点击头像进入Settings -> SSH and GPG keys -> New SSH key,将复制的信息粘贴到该处。
ide

五、测试是否成功$ssh -T git@github.com测试

提示“Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.”说明添加成功。ui

git上传本地代码到github

1.github新建Repository3d


Repository地址为code

更改Settings里GitGub Pages的source为master branch选项能够获取项目静态地址,能够发布静态页面。

二、打开项目文件夹,使用git命令窗口,执行如下代码复制刚刚建立的仓库到本地

$ git clone https://github.com/zhaohuihuizoe/test.git

三、将要上传的代码放到该文件夹中

四、执行git add .

五、添加注释语句,执行git commit -m "注释语句"

六、同步到仓库,执行git push origin master

七、刷新仓库地址,能够看到新增的文件已经上传到git上了

相关文章
相关标签/搜索