前言

新建个仓库,提交代码提示错误
git push origin master 提示以下错误
fatal: unable to access ‘https://gitee.com/xxx/xxx.git/’: Failed to connect to 127.0.0.1 port 7890: Connection refused

一、端口

1. 问题

fatal: unable to access ‘https://gitee.com/xxx/xxx.git/’: Failed to connect to 127.0.0.1 port 7890: Connection refused

致命:无法访问’https://gitee.com/xxx/xxx.git/':无法连接到127.0.0.1端口7890:连接被拒绝

2. 解决

(1)打开网络和interent

在这里插入图片描述

(2)设置代理

在这里插入图片描述

(3)设置本地代理

在终端输入以下命令,设置 Git 使用本地代理:

git config --global http.proxy http://127.0.0.1:7890

(4)校验

设置完成后,可以通过以下命令检验是否设置成功:

git config --global -l

正常来说,这里就解决了,但是依旧push失败,报错如下

二、问题2——身份验证失败

1. 身份验证失败

fatal: Authentication failed for ‘https://gitee.com/xxx/ql-xxx.git/’
致命:“”的身份验证失败https://gitee.com/xxx/ql-xxx.git/’

2.解决

(1)清空git存留的用户名和密码:

git config --system --unset credential.helper

注意点:需要以管理员身份执行,不然没有权限

(2)输入账号密码即可

三、问题3——需求先拉取,后提交

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

提示:更新被拒绝,因为您当前分支的提示已落后
提示:它的远程对应物。整合远程更改(例如。
提示:‘git pull…’)在再次推动之前。
提示:有关详细信息,请参阅“git push-help”中的“关于快进的注意事项”。

先拉取,后提交即可

git pull origin master
git push origin master

四、问题4——上游有分支了

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

致命:当前分支主机没有上游分支。
要推动当前分支并将远程设置为上游,请使用
git push --set-upstream origin master

五、账号密码错误提示

remote: [session-b942578c] da: Incorrect username or password (access token)
fatal: Authentication failed for ‘https://gitee.com/xxx/xxx.git/’
remote:[session-b942578c]da:用户名或密码(访问令牌)不正确
致命:“”的身份验证失败https://gitee.com/xxx/xxx.git/’

这个简单,就是账号或者密码打错了


总结: 、

代理解决不了的,重置即可。
需要注意的是,重置后每次提交和拉取都需要输入账号和密码,执行以下命令即可

git config --global credential.helper store

Logo

欢迎加入DeepSeek 技术社区。在这里,你可以找到志同道合的朋友,共同探索AI技术的奥秘。

更多推荐