You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux Mint 21下Git推送报错:URL含换行/凭证解析失败求助

解决Git推送至GitHub的URL解析错误

问题根源

从报错信息可定位两个核心问题:

  1. 远程仓库URL包含换行符,触发解析警告
  2. 重复添加.git后缀(出现myownrepo.git.git),导致凭证URL解析失败

修复步骤

1. 删除错误的远程仓库配置

先清除已添加的异常origin:

git remote remove origin

2. 重新配置正确的远程仓库URL

确保URL末尾不要加斜杠,也不要重复.git后缀:

git remote add origin https://github.com/myusername/myownrepo.git

3. 验证远程配置有效性

执行命令确认配置正确:

git remote -v

正常输出应如下:

origin  https://github.com/myusername/myownrepo.git (fetch)
origin  https://github.com/myusername/myownrepo.git (push)

4. 重新执行推送操作

git push -u origin main

额外排查:清理潜在的换行符问题

若仍出现URL换行警告,检查配置文件是否存在异常:

# 查看全局Git配置
git config --global --list
# 查看本地仓库配置
git config --local --list

如果发现remote.origin.url值带有换行,直接修正:

git config --local remote.origin.url "https://github.com/myusername/myownrepo.git"

内容的提问来源于stack exchange,提问作者Danu Pratama

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 18:10:29