git fetch 操作时报错:fatal: ‘origin‘ does not appear to be a git repository

报错:

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

上面的报错翻译过来就是

致命错误:“origin”似乎不是git存储库
致命错误:无法从远程存储库读取。

vscode安装了一个git管理插件叫gitLens,如下
在这里插入图片描述

本来是想删除远程分支的,之前一直都是指令操作:git push origin :[branch],结果今天手欠,想用插件中的菜单删除远程分支,结果不明白菜单的含义,导致出现了以上错误。操作如下:
在这里插入图片描述

当前的这个操作,其实是删除了本地与远程仓库的关联;可以执行指令git remote -v来查看是否与远程仓库有关联,如果什么都没有显示,则表示断开了与远程仓库的关联。

-v:verbose
git remote -v:获取git的远程详细信息

PS E:\Workspace\wanghx-front> git remote -v
PS E:\Workspace\wanghx-front>

这时候需要重新添加一下远程仓库地址,找到你的git仓库的远程地址,也就是HTTP或者SSH的那个链接,哪个能用用哪个,有些公司用的HTTP链接地址,还有的公司是SSH,各取所需。
在这里插入图片描述
添加远程仓库地址:

PS E:\Workspace\wanghx-front> git remote add origin https://gitee.com/moaijun/breaking-news.git
PS E:\Workspace\wanghx-front>

再次查看,就显示出关联的远程仓库了。

PS E:\Workspace\wanghx-front> git remote -v
origin  https://gitee.com/moaijun/breaking-news.git (fetch)
origin  https://gitee.com/moaijun/breaking-news.git (push)
PS E:\Workspace\wanghx-front>

这时候就可以进行fetch、pull、push等分支操作指令了。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
当你在使用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报错:‘origin‘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: ‘origin‘ 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 ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值