Can someone explain why git remote origin cannot be changed from livepost.git to europeanexplorer.git? I tried following the directions, but documentation states that error: Could not remove config section 'remote.origin'
means the file doesn't exist which clearly seems to not be the case here.
$ git remote -v
origin https://github.com/harrisongill/livepost.git (fetch)
origin https://github.com/harrisongill/livepost.git (push)
$ git remote rm origin
error: Could not remove config section 'remote.origin'
$ git remote set-url origin https://github.com/harrisongill/europeanexplorer.git
$ git remote -v
origin https://github.com/harrisongill/livepost.git (fetch)
origin https://github.com/harrisongill/livepost.git (push)
origin https://github.com/harrisongill/europeanexplorer.git (push)
$ git remote rm origin
$ git remote -v
origin https://github.com/harrisongill/livepost.git (fetch)
origin https://github.com/harrisongill/livepost.git (push)
EDIT: Add git config
$git config --list
Harrisons-MacBook-Pro:European Explorer harrison$ git config --list
user.name=Harrison Gill
user.email=my email
remote.origin.url=https://github.com/harrisongill/livepost.git
core.repositoryformatversion=0
core.filemode=true
core.logallrefupdates=true
core.precomposeunicode=true
All command line commands write strings into files in your .git/
directory.
Remotes are configured conveniently inside .git/config
file, and I think that's what Chris was referring to.
So, if you do vim .git/config
you should see something like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
url = [email protected]:harrisongill/livepost.git
fetch = +refs/heads/*:refs/remotes/origin/*
and perhaps something else that's confusing to git in the [remote "origin"]
section :P.
Why did it get messed up? I don't know. However just manually editing this file should set you straight :)
Get rid of the extra stuff and you should be good to go :)
Original answer Jan 2014
As commented in "Cannot remove remote origin
", the error message error: Could not remove config section 'remote.origin'
means there is no remote 'origin' in your Git config file.
At least not in your local config file.
I just tested adding a remote "origin" section in my global config file, and I got what you have:
C:\Users\VonC\prog\git\tests\21195717\t>git config --global --edit
C:\Users\VonC\prog\git\tests\21195717\t>git remote -v
origin https://a.com/b (fetch)
origin https://a.com/b (push)
C:\Users\VonC\prog\git\tests\21195717\t>git remote rm origin
error: Could not remove config section 'remote.origin'
Check your global config file:
git config --global --edit
Update February 2016
Git 2.8 will update that error message to "no such remote
".
See commit a31eeae, commit cc8e538, commit 674468b, commit bc60f8a (16 Feb 2016) by Thomas Gummerer (tgummerer
).
(Merged by Junio C Hamano -- gitster
-- in commit ae2f255, 26 Feb 2016)
remote: actually check if remote exits
When converting the git remote command to a builtin in 211c89 ("Make git-remote a builtin"), a few calls to check if a remote exists were converted from:
if (!exists $remote->{$name}) { [...]
to:
remote = remote_get(argv[1]); if (!remote) [...]
The new check is not quite correct, because
remote_get()
never returns NULL if a name is given.
This leaves us with the somewhat cryptic error message "error: Could not remove config section 'remote.test'
", if we are trying to remove a remote that does not exist, or a similar error if we try to rename a remote.Use the
remote_is_configured()
function to check whether the remote actually exists, and die with a more sensible error message ("No such remote: $remotename
") instead if it doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With