解决git fatal: No remote repository specified.

今天在电脑上,想将gitee切换到github,使用了【git remote rm origin
】,没想到重新关联远程库时,不管是gitee还是github都是失败,直接【git pull】出现如下错误:

user ~/c/xxx$git pull
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

百度了一下都说.git/config的配置出问题了。
解决方法是从其他项目里拷贝一份config过来,再改一下里面的url就可以了,或者用下面的模板:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = false
[remote "origin"]
        url = https://github.com/Demo/xxx.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        pushurl = https://github.com/Demo/xxx.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

把其中换成你项目的地址就可以了:

url = https://github.com/Demo/xxx.git
pushurl = https://github.com/Demo/xxx.git

然而我出现的并不是这种情况,我在对应的目录下查找【.git】文件,哎呀我去,竟然连这个文件都找不到了。于是我二话不说、立马横刀,直接来了句【git init】创建【.git】文件,然后重新【pod install】,嘿嘿嘿~完美解决问题,详见下图:
图一

图二

整个过程下来反思了一下这个问题,我这种情况会报这种错误,可能也有如大多数博客上上说的【.git/config】有问题,这时候千万不要不知道在哪里找这个文件了,否者就搞笑了,当然其具操作如上图。

猜你喜欢

转载自blog.csdn.net/weixin_38633659/article/details/82499564
今日推荐