1 注册github账号
1.1 进入github官网:https://github.com/ 点击 Sign in
,

1.2 转到登录页面,然后点Creat an account

1.3 填写相关信息注册账号

2 在github上创建仓库
2.1 创建仓库
点击左侧New
图标,或者右侧的“+”都可以创建仓库。

2.2 添加相关信息
填写完点击Create repository

2.3 仓库创建完成

3 安装git
3.1 下载
下载地址 https://git-scm.com/

下载后点击安装即可。
3.2 安装完成
主要用到的是 Git Bash

4 上传代码到github的仓库中
4.1 下载刚刚创建的仓库到本地
先复制仓库地址:https://github.com/xxxx/test.git

在本地打开右键打开Git Bash

输入命令:git clone https://github.com/用户名/test.git

可以看到如下文件,.git为隐藏文件

4.2 编写代码
如编写test.py文件

4.3 上传代码
(1)将代码提交到暂存区, 输入git add .

(2)提交代码到本地git库中git commit -m "备注信息"

第一次使用git需要填写,相关信息,以后提交就不用了,安装提示输入如下命令即可:git config --global user.email "you@example.com"
git config --global user.name "Your Name"

(3) 提交代码到github
git push origin master
第一次使用git需要填写用户名和密码,之后就不需要了。

可以看到提交成功

再回到浏览器,刷新就可以看到test.py已经提交到github上了。

5 用到命令总结
- 从github下载到本地:
git clone 仓库链接
- 将代码提交到暂存区:
git add .
- 提交代码到本地git库中:
git commit -m "备注信息"
- 提交代码到远程主机(github上) :
git push origin master