准备工作

1、注册GitHub账号

进入GitHub官网https://github.com/github,创建一个账户。

2、下载GitHub Desktop for Windows

如下图,先在GitHub上创建一个仓库,创建成功后,可以看到 有个Set up in Desktop 按钮。

github copilot device code 登录 github desktop登录_上传

 然后单击 Set up in Desktop ,进入如下界面:

github copilot device code 登录 github desktop登录_客户端_02

下载GitHub的Windows客户端,下载完直接运行即可。

github copilot device code 登录 github desktop登录_客户端_03

 

3、打开GitHub Desktop,如下图,输入账号和密码进行登录。

github copilot device code 登录 github desktop登录_上传_04

 

github copilot device code 登录 github desktop登录_github_05

创建第一个代码库

认识界面

我们来建立第一个仓库,点击左上角的File打开之后有五个选项,New repository,Add local repository,Clone repository,Options,Exit。

 

github copilot device code 登录 github desktop登录_github_06

 

我们首先来新创建一个仓库:

1、点击左上角的File —> New repository,创建一个新的代码库,填写相应的信息:

 

github copilot device code 登录 github desktop登录_Desktop_07

新建之后,如下图所示:

 

github copilot device code 登录 github desktop登录_Desktop_08

在电脑上找到我们本地路径,目录结构如图所示:(注意:.git文件是隐藏文件,且不能删除)

 

github copilot device code 登录 github desktop登录_客户端_09

此时,只是在本地建立好了相应的本地仓库,GitHub网站上面还未上传。点击客户端上的 Publish repository 按钮进行上传,如下图:

github copilot device code 登录 github desktop登录_上传_10

 

对要上传的仓库进行描述:

github copilot device code 登录 github desktop登录_Desktop_11

 

上传完后,新建的仓库已经成功提交到GitHub,登录GitHub网站,进入仓库(点击右上角头像,选择Your repositories),可以看到我们刚刚创建的 DevOps 仓库。

github copilot device code 登录 github desktop登录_github_12

2、打开我们的本地路径(如果忘记也不要紧,在GitHub客户端里鼠标右键我们的仓库,选择选择Show in Explorer,这样我们就可以转到刚刚新建的本地仓库路径下),在里面新建文件test.txt。

github copilot device code 登录 github desktop登录_客户端_13

此时,打开GitHub客户端可以看到 DevOps 仓库有一个新的消息:

 

github copilot device code 登录 github desktop登录_客户端_14

github copilot device code 登录 github desktop登录_Desktop_15

3、在客户端的下方填写相关描述,点击 Commit to master 进行提交。

github copilot device code 登录 github desktop登录_上传_16

 

4、点击 Commit to master 只是让GitHub客户端记录这次进行的改动,并不会直接提交到GitHub上面去,相当于一次游戏存档,在将来的某一天如果想重玩这个存档,可以点击 Commit to master 下面的 Undo 按钮,让项目还原到这次记录的状态。如果想将本地的改动提交到GitHub网站上,点击 Push origin 上传到GitHub即可。

github copilot device code 登录 github desktop登录_github_17

 

5、现在可以到自己的GitHub主页上查看DevOps仓库,可以看到我们新建的 test.txt 文件已经出现在主页上了。

github copilot device code 登录 github desktop登录_Desktop_18

之后的每次改动,只要重复第3、4、5个步骤即可。

Add local repository:

如果本地有工程,就可以使用Add添加

Clone repository:

复制仓库

 

这时在左侧的目录中,新建项目从other目录换到了GitHub目录下,并且右上方的云图标Public也换成了更新图标Sync,本地项目更改了,要更新到服务器上,就点击它

最后还说点更改本地仓库地址,它默认的是在系统用户下(系统盘),最好更改到其它盘,以防以后如果重装系统时不被删除,也不会占用系统内存。点击界面右上方的齿轮设置图标.