GitHub代码管理
下载安装好Git
一、配置ssh秘钥:
配置电脑和远程仓库账号的身份认证秘钥
配置成功之后,如果不更换电脑,只是新注册了一个github账号,则秘钥不需要重新生成,在新的github账号中配置下秘钥就可以了。
配置成功之后,如果换了新电脑,那就需要从头做一遍
1、右键选中git bash
![](https://img.haomeiwen.com/i14053342/2b5ebc8d77d87148.png)
2、生成ssh秘钥
git base中执行下列命令,生成秘钥
ssh-keygen -trsa -C "你的github邮箱"
![](https://img.haomeiwen.com/i14527812/360bf6e6214578f9.png)
3、把本地秘钥添加到远程仓库配置里
找到id_rsa.pub这个秘钥文件路径
打开方式:Notepad++
![](https://img.haomeiwen.com/i14527812/679091e20ce47af8.png)
![](https://img.haomeiwen.com/i14527812/3e1b2297b5aff19e.png)
4、全选-复制里面的内容
5、打开远程仓库Github——设置(Settings)
![](https://img.haomeiwen.com/i14527812/cab4d30b09baff7d.png)
6、点击新增ssh秘钥
![](https://img.haomeiwen.com/i14527812/b44fb56e9dd87992.png)
![](https://img.haomeiwen.com/i14527812/a699cb9c2da5586f.png)
7、测试秘钥是否配置成功
ssh -T git@github.com
![](https://img.haomeiwen.com/i14527812/2a99ba3062124d0a.png)
二、新建github项目,上传本地代码
1、新建一个远程仓库(github项目)
![](https://img.haomeiwen.com/i14527812/04d07aaa7ebf6578.png)
![](https://img.haomeiwen.com/i14527812/092ccb5521b40641.png)
1.1新建仓库完成
![](https://img.haomeiwen.com/i14527812/e40a04c32eb054d7.png)
2、初始化本地仓库
检查本地仓库是否初始化过
打开项目文件夹,不存在.git这个隐藏文件夹也说明没有初始化过git仓库
![](https://img.haomeiwen.com/i14053342/eee51dc887ed69cd.png)
2.1 git init 初始化本地仓库
![](https://img.haomeiwen.com/i14053342/0e184eba04423517.png)
3、创建.gitignore文件,设置不需要上传的文件
![](https://img.haomeiwen.com/i14053342/0c7ce5c3a81272ae.png)
4、git add --all把代码文件添加到本地仓库
执行git add --all命令
![](https://img.haomeiwen.com/i14053342/84ef7d53dd18cc37.png)
5、git commit 封板
git commit -m "描述信息"
![](https://img.haomeiwen.com/i14053342/c3a0534a5de72a9e.png)
6、绑定远程仓库地址
![](https://img.haomeiwen.com/i14053342/ff10c049476596ca.png)
![](https://img.haomeiwen.com/i14053342/e9e12a082c6a7195.png)
7、git push上传代码到远程仓库
执行git push -u origin master 上传代码
![](https://img.haomeiwen.com/i14053342/cf338837c3cd8267.png)
7.1上传代码:pycharm的快捷操作
![](https://img.haomeiwen.com/i14053342/64dab478953804c3.png)
网友评论