Trevor Burnham
Trevor Burnham

Reputation: 77426

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?

Upvotes: 49

Views: 42525

Answers (4)

Julian Pechacek
Julian Pechacek

Reputation: 180

Look in the global git config file C:\Users\yourusername.gitconfig or /etc/.gitconfig

If [remote "origin"] is configured in the .gitconfig file, (or locally .git\config) then the "$git remote rm origin" command will not work.

Upvotes: 0

Denis Kutlubaev
Denis Kutlubaev

Reputation: 16184

I solved my problems this way. First I opened up the config file using vim with the following command

$ vim .git/config

I modified my file to this below:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = false
[branch "master"]
[remote "origin"]
        url = [email protected]:xxx.git
        fetch = +refs/heads/*:refs/remotes/origin_iOS/*

So now, when I give a command git push it understands, because by default it pushed to origin and it is set to my origin_iOS in my server.

You can check your origin config by remote -v command:

$ git remote -v
origin  [email protected]:xxxx.git (fetch)
origin  [email protected]:xxx.git (push)

If you don't have 'origin', you will have troubles with a usual 'git push' as I did. I had to type 'git push origin_iOS master', because I had in my config 'origin_iOS'

Upvotes: 0

Pablo Fernandez heelhook
Pablo Fernandez heelhook

Reputation: 12553

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://..." 

Upvotes: 80

Dillon Benson
Dillon Benson

Reputation: 4440

Open the .git directory and edit the config file where it says [remote "origin"]

Upvotes: 2

Related Questions