登 录 
注 册
Git 删除远程分支报错 error: Could not remove config section 'remote.origin' 解决办法
发布时间: 2016-08-30
浏览次数: 519
发布人:
  
东川供求信息
  •      这是我的Github新创建的一个Repository


    [java] view plain copy
    echo # springDemo >> README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin https://github.com/xuxinpie/springDemo.git
    git push -u origin master
    上面无非就是将本地工程同步到github上, 但再使用git remote add origin的时候可能会出现的如下错误

    $ git remote addorigin git@github.com:xuxinpie/springDemo.git

    错误提示:fatal: remote origin already exists.

    解决办法:

    $ git remote rm origin

    然后在执行:$ git remote add origin git@github.com:xuxinpie/springDemo.git 就不会报错误了

    如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容

    找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
    找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!


    但是实际是我依然存在问题, 因为我的目录下gitconfig根本没有这一行,发现网上的解决方法都无法解决我的问题,自己思考了一下:

    发现问题存在于自己的eclipse中的git插件,里面配置了remote origin, 所以每次操作的时候都会走默认的远程分支。

    解决办法:打开eclipse-->windows-->perference-->Git-->Configuration

    里面的User Settings里面删除对应的remote origin项(我的已删除,可以脑补一下)



    删除之后再git bash里面重新$ git remote rm origin 成功。希望之前在eclipse中使用git插件配置过remote origin的同志们注意下,不要再踩这个坑了,

  • 请说在东川区供求信息网看到此信息
CopyRight © 2014-2022 昆明英信科技有限公司 All Rights Reserved    滇ICP备14006165号-1
滇公网安备 53011302530117号