fatal: ‘origin‘ does not appear to be a git repository

1. Go编译报错信息

E:\work\hqsource\stock\quote_sh_l2_parser>go build
go: xxxxxxx/yyyyyyyy/quote_lib@v0.3.115-0.20220302053425-232076327f09: invalid version: git ls-remote -q origin in C:\Go\repository\pkg\mod\cache\vcs\87198654213a7c861ce67251dbddf3f94fb383755ea8e89812eb7f12fc9c666e: exit status 128:
        fatal: 'origin' does not appear to be a git repository
        fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.

go编译时,git需要拉取对应的依赖库,拉取依赖库时,会先去GOPATH路径下的缓存去查找,如果缓存不正确,就有可能导致莫名其妙的问题。上面问题关键在这里

invalid version: git ls-remote -q origin in C:\Go\repository\pkg\mod\cache\vcs\87198654213a7c861ce67251dbddf3f94fb383755ea8e89812eb7f12fc9c666e

2. 解决方案

 删除go同步依赖库的缓存,很多时候可能由于缓存有问题,造成了莫名其妙的错误,就类似于Java项目的maven时,依赖库没有正确下载,后续因为缓存库引入有问题,需要重新清理一下缓存才能正确编译和使用。

现在我们找到上面的文件夹,然后删除此文件夹。文件的路劲根据提示自己确认。我的需要删除的文件夹如下

C:\Go\repository\pkg\mod\cache\vcs\87198654213a7c861ce67251dbddf3f94fb383755ea8e89812eb7f12fc9c666e

当你在使用git push origin master命令时,出现fatal: 'origin' does not appear to be a git repository的错误提示,这通常是因为你的本地仓库没有与远程仓库进行关联所导致的。解决这个问题的方法有两种: 1. 添加关联:你可以使用命令git remote add origin [远程仓库地址来添加关联,将远程仓库与本地仓库进行关联,例如git remote add origin git@github.com:username/repo.git。然后再次尝试git push origin master命令即可。 2. 重新关联:如果已经添加了关联但仍然出现该错误,可能是关联信息错误导致的。你可以使用命令git remote set-url origin [正确的远程仓库地址来重新设置关联信息,确保所使用的远程仓库地址是正确的。然后再次尝试git push origin master命令。 通过以上方法中的一种,你应该能够解决fatal: 'origin' does not appear to be a git repository的错误提示。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [git报错:&lsquo;origin&lsquo;does not appear to be a git repository的解决方法](https://blog.csdn.net/willingtolove/article/details/113187468)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [[转]git-报错总结-fatal: &lsquo;origin&lsquo; does not appear to be a git repository](https://blog.csdn.net/weixin_40634003/article/details/122984201)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值