上传项目文件到Github,并解决fatal: unable to access问题,100%成功

一、背景

Github我们用的最多的就是clone别人的代码,但有时我们也希望上传自己的项目或代码。但github上传文件还是比较复杂的,中间会有许许多多奇怪的问题,因此记录一下其过程。

二、Github上传文件

1. 申请Github账号

这里默认你已经有Github账号,因为Github是国外的网站,所以需要梯子,不然很容易登录不进去Github官网。

2. 安装git工具

向github上传文件,需要先安装git工具,因为我是在windows系统,所以用的是,Git for Windows,下载地址如下,下载后双击exe文件,选择好安装路径后,一路下一步即可成功安装。

下载地址:https://gitforwindows.org/

进入Git for Windows官网,点击Download即可。

在这里插入图片描述

小tip:另外一个备选git工具,官网:https://git-scm.com/

3. 在Github个人主页,创建项目repository
a. 个人Github主页,点击New在这里插入图片描述
b. 进行repository仓库名字、描述设置

这里主要填三个东西就行。
第一个是项目名称,也就是Repository name
第二个是项目描述,也就是Description (optional)
第三个勾选上Add a README file
最后拉到最下面,点击绿色的Create repository,成功创建repository
在这里插入图片描述

下面是具体上传文件步骤,非常重要

c. 进入需要上传的文件夹,空白处右键,选择Open Git Bash here**

这里一定要进入到正确到目录,也就是需要上传文件的同级目录,即初始化后的文件夹为:
在这里插入图片描述

d. 初始化

终端输入git init
在这里插入图片描述
此时,我的A file for Premiere Pro2018文件夹下会出现.git文件,如果你没有,则点击上方的查看—显示—隐藏的项目

e. 添加文件

终端输入git add *

注意:有的博客说这里输入git add .,但我这里输入这个命令不行,得用星号才可以。

f. 添加文件

终端输入git commit -m "first commit"

注意,此时会报错,如下所示:

Author identity unknown

*** Please tell me who you are.

Run

git config --global user.email “[email protected]
git config --global user.name “Your Name”

to set your account’s default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got ‘dlut@LAPTOP-R0I3D1SV.(none)’)

在这里插入图片描述
意思缺少用户名和邮件地址。

解决办法:
进入之前d步骤git init命令创建的.git文件夹,打开config文件,用记事本打开就可以,末尾添加以下内容:

[user]
email = 136797300@qq.com
name = Dreamer-DLUT

注意这里的email是你自己的Github邮箱,名字也是你自己的Github用户名
在这里插入图片描述
添加完后,保存关闭即可。

重新执行git commit -m "first commit" 命令,然后成功了
在这里插入图片描述

g. 输入下面命令

终端输入git remote add origin https://github.com/Dreamer-DLUT/Adobe-Premiere-Pro2018.git

其中https后面是你自己前面ab步骤创建的repository链接。

g. 输入上传命令

终端输入git push -u origin master

至此,成功上传项目到Github,查看方法
进入我们创建的项目,然后branches分支,选择master即可。

在这里插入图片描述

三、Fatal: unable to access ‘https://github. com/Dreamer-DLUT/Adobe-Premiere-Pro2018.jit’: Recy failure: Connection was reset 解决方法

之前还有一个教程说要在git使用git clone https://github.com/Dreamer-DLUT/Adobe-Premiere-Pro2018.git命令,然后报错如下:

Fatal: unable to access ‘https://github. com/Dreamer-DLUT/Adobe-Premiere-Pro2018.jit’: Recy failure: Connection was reset

在这里插入图片描述
解决方法很简单:

windows系统设置搜索代理,然后点击编辑按钮:
在这里插入图片描述
在这里插入图片描述
手动设置代理处点击设置,此处端口号改为7890

在这里插入图片描述
回到git,输入命令:git config --global http.proxy http://127.0.0.1:7890
问题解决,后面再使用git clone不会报错了

上传成功展示:Good
在这里插入图片描述

四、Github删除repository仓库
  1. 进入需要删除的repository仓库,点击上方的Settings
    在这里插入图片描述
  2. 拉到最后的Danger Zone,选择Delete this repository

在这里插入图片描述
3.根据提示输入删除需要删除repository库的名字即可。

参考:
https://www.bilibili.com/video/BV1Xs4y1i7id/?spm_id_from=333.337.search-card.all.click&vd_source=ea5c910bfe0c11f0edf9f3a8da1dd52a

https://blog.51cto.com/u_15983333/6252007

猜你喜欢

转载自blog.csdn.net/Time_Memory_cici/article/details/134462657