通过VSCode上传文件夹至github

如果是第一次连接github账户,则需要设置ssh。

1
2
3
4
5
6
7
8
9
查看用户名和邮箱地址:
$ git config user.name

$ git config user.email
修改用户名和邮箱地址:

$ git config --global user.name "xxxx"

S git config --global user.email "xxxx"

生成SSH Key的秘钥对:参考博客

1
2
3
ssh-keygen -t rsa  #在某个位置生成秘钥对,文件位置会在结果给出
将id_rsa.pub文件内容复制粘贴到github中
ssh -T git@github.com #运行该命令进行验证

首先在GitHub上创建一个Repository,复制url

在一个空文件夹中打开终端,输入

1
git clone url

而后即可用VSCode打开文件夹,使用其功能进行push pull功能了

上传步骤为:commit all ->push
拉取即为pull
commit时需要写一些提交备注。
实际上VSCode还提供其他的一堆命令,不过这几个命令就够用了,出了问题再用其他的

tip:
1 拉取仓库时修改url

1
2
git clone git://github.com/spdk/spdk
git clone https://github.com.cnpmjs.org/spdk/spdk

而后在.git/config文件中改回来,这样拉取的速度可以加快。
vscode设置git文件可见

2 上传时不能开代理,否则会出现一些问题
OpenSSL SSL_read: Connection was reset, errno 10054
实际上我只是因为打开了clash,不是上述的原因,不过可以通过以下命令修改github最大文件限制

1
git config  --global http.postBuffer 5242880003

3 GnuTLS recv error (-110): The TLS connection was non-properly terminated
1
2
3
4
5
6
7
8
9
10
11
12
 #方法1
apt-get install gnutls-bin
git config --global http.sslVerify false
git config --global http.postBuffer 1048576000
#方法2
重置代理,解决
git config --global --unset https.https://github.com.proxy
git config --global --unset http.https://github.com.proxy
//取消http代理
git config --global --unset http.proxy
//取消https代理
git config --global --unset https.proxy

方法3
Stack Overflow中里说需要用源码重新编译
方法4(我自己的方法):

1
2
3
4
5
6
#遇到该问题时,先检测与github.com是否连通
ssh -T git@github.com #-T 不显示终端,只显示连接成功信息
报错The authenticity of host 'github.com (20.205.243.166)' can't be established
输入yes,回车后再运行 ssh -T git@github.com,此时成功
Hi 1020xyr! You've successfully authenticated, but GitHub does not provide shell access.
而后推送到github就没有报错了

不过我之前也成功推送过,不知道具体原因。。。

迁移至gitee..,github访问太多问题
好像用ssh方式推送能避免很多问题,不过已经迁移完了。
git remote add增加远程仓库,也可以直接修改./git/config文件url


Git Clone错误解决:GnuTLS recv error (-110): The TLS connection was non-properly terminated