Cannot remove remote origin
I'm running git 1.8.0 on OS X, and every new git repo seems to have a remote called "origin":
$ git init
$ git remote
origin
What's odd is that I can't remove it:
$ git remote remove origin
error: Could not remove config section 'remote.origin'
And therefore I can't add a new remote called origin
. Why is this? What can I do to change it?
You should be able to remove origin
with
git remote rm origin
Not that you need to, you can just change the origin
with set-url
git remote set-url origin "https://..."
WARNING: Read carefully before attempting
This error can also be caused if you copy and paste a project that has git initialized. I would only recommend this in a new project where you don't care about the previous history.
Background
I ran into this error when I just copied and pasted a project. When I ran git status
I saw the diff between the new project and the one that I pasted in.
Solution
All I did to fix it was to go to the command line and cd
into the project and run
rm -f -r .git
Which got rid of the old .git file from the previous project. Then I ran git init
for a new .git file then everything was fine.
Likewise for this error, if you do not need the previous git records, then this is fast easy way to do it.
打开.git目录并编辑配置文件,在其中说[remote“origin”]
链接地址: http://www.djcxy.com/p/27070.html上一篇: 如何克隆仅Git存储库的子目录?
下一篇: 无法移除远程原点