2.4 KiB
2.4 KiB
HTTP 认证问题解决方案
问题现象
remote: Unauthorized
fatal: Authentication failed for 'http://101.43.95.130:8080/test-project/'
问题原因
在 DEVELOPMENT_BECOME_ANY_ACCOUNT 模式下,HTTP 认证可能需要特殊处理。
解决方案
方案一:配置 Git 凭证存储(推荐)
在您的本地电脑上执行:
cd /d/ttt/test-project
# 配置 Git 凭证存储
git config credential.helper store
# 配置用户名
git config credential.http://101.43.95.130:8080.username renjianbo
# 或者全局配置
git config --global credential.helper store
git config --global credential.http://101.43.95.130:8080.username renjianbo
# 重新推送
git push origin HEAD:refs/for/master
当提示输入密码时,直接按回车(留空)。
方案二:在 URL 中使用空密码
cd /d/ttt/test-project
# 修改远程 URL,包含用户名和空密码
git remote set-url origin http://renjianbo:@101.43.95.130:8080/test-project
# 推送
git push origin HEAD:refs/for/master
方案三:使用 Git Credential Manager
如果使用 Windows Git Credential Manager:
cd /d/ttt/test-project
# 清除已保存的凭证
git credential reject <<EOF
protocol=http
host=101.43.95.130
port=8080
EOF
# 重新推送,会弹出凭证对话框
git push origin HEAD:refs/for/master
在对话框中:
- Username:
renjianbo - Password: 留空或输入任意字符
方案四:手动创建凭证文件
在 Windows 上,可以手动创建凭证文件:
# 创建凭证文件(如果不存在)
mkdir -p ~/.git-credentials 2>/dev/null || true
# 添加凭证(格式:protocol://username:password@host:port)
echo "http://renjianbo:@101.43.95.130:8080" >> ~/.git-credentials
# 配置 Git 使用凭证文件
git config --global credential.helper store
# 推送
cd /d/ttt/test-project
git push origin HEAD:refs/for/master
快速修复(最简单)
执行以下命令:
cd /d/ttt/test-project
# 方法 1:配置凭证存储和用户名
git config credential.helper store
git config credential.http://101.43.95.130:8080.username renjianbo
# 方法 2:修改 URL 包含空密码
git remote set-url origin http://renjianbo:@101.43.95.130:8080/test-project
# 推送
git push origin HEAD:refs/for/master
如果还是不行
可能需要检查服务器端的 HTTP 认证配置。请告诉我具体的错误信息,我会继续排查。