git提示:Fatal:could not fetch refs from ....

本文解决在Git服务器上新建项目时遇到的“Fatal:couldnotfetchrefs”错误。通过在项目中添加至少一个文件再进行clone操作,成功解决了因项目为空导致的下载失败问题。

 在git服务器上新建项目提示:

Fatal:could not fetch refs from git.....

 

百度搜索毫无头绪,最后翻墙google,找到这篇文章http://www.voidcn.com/blog/chenjh213/article/p-4977547.html

其中:

对,就是在新建项目的时候不能为空文件夹项目,否则没有内容下载,

故在项目中增加个文件后再次clone

成功了。

 

转载于:https://www.cnblogs.com/hwaggLee/p/5948531.html

Started by user zhaoshihao Running as SYSTEM Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\jj The recommended git tool is: NONE No credentials specified > git.exe rev-parse --resolve-git-dir C:\ProgramData\Jenkins\.jenkins\workspace\jj\.git # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url git@gitee.com:qwerrain/jx.git # timeout=10 Fetching upstream changes from git@gitee.com:qwerrain/jx.git > git.exe --version # timeout=10 > git --version # 'git version 2.49.0.windows.1' > git.exe fetch --tags --force --progress -- git@gitee.com:qwerrain/jx.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from git@gitee.com:qwerrain/jx.git at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1240) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1311) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1278) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1250) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522) at hudson.model.Run.execute(Run.java:1833) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:446) Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress -- git@gitee.com:qwerrain/jx.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2188) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:638) at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997) ... 12 more ERROR: Error fetching remote repo 'origin' Finished: FAILURE
最新发布
10-13
<think>嗯,用户遇到了Git的错误信息:“fatal: No remote configured to list refs from”。我需要根据提供的引用资料和系统指令来找出解决方案。首先,用户之前的问题是关于“git pull”出现的类似错误,而这次是“git ls-remote”出现同样的提示。这说明问题核心是Git仓库的远程配置缺失或损坏。 根据引用[4],用户之前的问题是因为.git/config配置错误,解决方案是复制其他项目的config或手动修改。这可能同样适用于当前的情况。另外,引用[1]和[2]也提到,没有指定远程仓库会导致类似错误,需要重新关联远程仓库。引用[3]和[5]提到代理和SSH配置的问题,虽然当前错误可能不直接相关,但可以作为补充检查点。 接下来,我需要分步骤解决用户的问题。首先检查是否存在远程仓库,使用git remote -v。如果没有显示,就需要添加远程仓库,使用git remote add origin <url>。如果已经存在但配置错误,可能需要修改URL或者重新添加。另外,检查.git/config文件是否正确,可能需要手动编辑或者替换。还可以检查网络连接和代理设置,确保没有代理干扰,或者正确配置了SSH密钥。 需要确保用户正确执行这些步骤,并且每个步骤都有对应的命令示例,比如如何添加远程仓库,如何修改现有远程URL,如何检查配置文件。同时,要提醒用户如果从其他项目复制config文件,需要修改URL部分。此外,补充建议部分可以包括检查网络权限、代理设置和SSH配置,以覆盖其他可能的问题来源。 最后,生成相关问题,帮助用户进一步理解可能遇到的类似问题,比如如何添加远程仓库、修改现有远程配置等。这有助于用户未来自主解决问题。</think>### Git错误"fatal: No remote configured to list refs from"解决方案 该错误表示Git仓库缺少有效的远程仓库配置,可通过以下步骤排查解决: 1. **验证远程仓库配置** ```bash git remote -v ``` 若无任何输出,说明尚未配置远程仓库[^1][^2] 2. **添加远程仓库** ```bash git remote add origin https://github.com/用户名/仓库名.git ``` 需替换为实际仓库地址,支持HTTPS/SSH协议 3. **修改现有远程配置** ```bash git remote set-url origin https://gitee.com/用户名/仓库名.git ``` 适用于需要切换代码托管平台的情况[^4] 4. **手动修正配置文件** 检查`.git/config`文件是否包含: ```ini [remote "origin"] url = https://github.com/用户名/仓库名.git fetch = +refs/heads/*:refs/remotes/origin/* ``` 可复制其他正常项目的配置文件后修改URL[^4] 5. **检查网络连接** ```bash git config --global --unset https.proxy # 取消代理设置[^3] ping github.com # 测试网络连通性 ``` **补充建议:** - 确保仓库路径区分大小写 - 检查SSH密钥配置(使用`ssh -T git@github.com`验证)[^5] - 新仓库需先执行初始推送: ```bash git push -u origin master ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值