最近使用github × Source Tree开发时遇到了Connection was aborted && Couldn’t connect to server这俩问题,记录一下我解决问题的全流程
获取Github personal token
在设置的这里generate token,权限全部勾上就行,记得找个地儿保存好token不要问我怎么知道的
在Clone使用Token
原本git clone的指令如下 ( 加粗部分为仓库http链接 ) :
git clone https://github.com/<username>/<repo>.git
现在已经不能直接按上述使用了,需要在https://后加自己的token
git clone https://<your token>@github.com/<username>/<repo>.git
PS.别把<和 > 也写进去了
在Push使用Token
通过git remote查看当前url ( 一般为origin )
使用git remote set-url <url> https://<your token>@github.com/<username>/<repo>.git 设置该url的提交路径是走你的token进仓库的
之后正常的add commit push pull就可以了
问题解决
Connection was aborted && Couldn’t connect to server本质上是两个问题,一是权限不够无法访问,因此可以按上述token的方法解决,二是代理的问题,下面是我解决问题的流程。
Git Bash中
- git config --system --unset credential.helper
- git config --global --unset http.proxy
- git config --global --unset https.proxy
CMD中
- ipconfig/flushdns
Git Bash中
- 获取 token 并完成git remote set-url <url> https://<your token>@github.com/<username>/<repo>.git 设置
CMD中
- ipconfig/flushdns
之后就可以正常push/clone了