{"thread":{"id":"8452","subject":"How to remove invalid remote repository","startedAt":"2007-06-05T19:41:04Z","lastAt":"2007-06-05T20:57:08Z","messageCount":4,"participants":["Matt Seitz","Jan Hudec","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"44097","messageId":"8A00BB77B01133479F4A56D932A1132202906FD8@EX-401.mail.navisite.com","threadId":"8452","inReplyTo":null,"subject":"How to remove invalid remote repository","fromName":"Matt Seitz","fromEmail":"seitz@neopathnetworks.com","sentAt":"2007-06-05T19:41:04Z","receivedAt":"2007-06-05T19:41:04Z","isPatch":false,"sender":{"key":"seitz@neopathnetworks.com","avatar":null},"body":"I mistakenly entered the wrong directory name for \"git remote add\" (I\nentered the working tree directory name instead of the \".git\" directory\nname). \n\nSo \"git fetch\" fails with:\n\nfatal: 'origin': unable to chdir or not a git archive\nfatal: The remote end hung up unexpectedly\n\nCannot get the repository state from origin\n\nSo, I tried removing the remote tracking branches:\n\ngit branch -d -r root-etc/master\n\nBut that failed with:\n\nerror: remote branch 'root-etc/master' not found.\n\n\nSo I then tried recreating the remote reference:\n\ngit remote add root-etc /root/git/etc/.git\nBut that failed with:\n\nremote root-etc already exists\n\nSo, how can I remove the incorrect remote repository reference and\nreplace it with a correct one?\n\n[root@demo5 etc]# git config -l\ncore.repositoryformatversion=0\n\ncore.filemode=true\n\ncore.bare=false\n\ncore.logallrefupdates=true\n\ngui.geometry=811x591+781+0 107 172\n\nremote.root-etc.url=/root/git/etc\n\nremote.root-etc.fetch=+refs/heads/*:refs/remotes/root-etc/*\n\n[root@demo5 etc]# git version\n\ngit version 1.5.0.7\n"},{"id":"44099","messageId":"20070605201457.GB3240@efreet.light.src","threadId":"8452","inReplyTo":"8A00BB77B01133479F4A56D932A1132202906FD8@EX-401.mail.navisite.com","subject":"Re: How to remove invalid remote repository","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-06-05T20:14:57Z","receivedAt":"2007-06-05T20:14:57Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Tue, Jun 05, 2007 at 14:41:04 -0500, Matt Seitz wrote:\n> I mistakenly entered the wrong directory name for \"git remote add\" (I\n> entered the working tree directory name instead of the \".git\" directory\n> name). \n\nThere does not seem to be any 'git remote remove'. So you'll do it by\nchanging the config. Either with git-config, or by editing .git/config (it\n*IS* meant to be hand-edited).\n\n> [...]\n> So, how can I remove the incorrect remote repository reference and\n> replace it with a correct one?\n> \n> [root@demo5 etc]# git config -l\n> [...]\n> remote.root-etc.url=/root/git/etc\n                      ^^^^^^^^^^^^^\nThis is the URL. You can simply fix it either with \n    git-config remote.root-etc.url /root/git/etc/.git\nor by editing\n.git/config\n\n> remote.root-etc.fetch=+refs/heads/*:refs/remotes/root-etc/*\n\nThe section corresponding to these two entries in .git/config looks like:\n\n[remote \"root-etc\"]\nurl = /root/git/etc\nfetch = +refs/heads/*:refs/remotes/root-etc/*\n\nYou can tweak it to your heart's content. The documentation is in man pages\nof git-config and git-fetch.\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"},{"id":"44100","messageId":"alpine.LFD.0.98.0706051308090.4921@woody.linux-foundation.org","threadId":"8452","inReplyTo":"8A00BB77B01133479F4A56D932A1132202906FD8@EX-401.mail.navisite.com","subject":"Re: How to remove invalid remote repository","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-06-05T20:18:14Z","receivedAt":"2007-06-05T20:18:14Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 5 Jun 2007, Matt Seitz wrote:\n>\n> I mistakenly entered the wrong directory name for \"git remote add\" (I\n> entered the working tree directory name instead of the \".git\" directory\n> name). \n\nNow, that should be fine. You don't have to add the .git name, git will \nfigure it out on its own.\n\n> So \"git fetch\" fails with:\n> \n> fatal: 'origin': unable to chdir or not a git archive\n> fatal: The remote end hung up unexpectedly\n\nWell, this is because you apparently didn't call the remote \"origin\", but \nsomething else. So when you do\n\n\tgit fetch\n\nwithout giving any remote name at all, git will *default* to using \n\"origin\" as a remote, but since no such remote name exists, it will try to \nuse that remote as a pathname (which is admittedly a bit silly, but git \ndoesn't know that), and so what happened was that it was trying to fetch \nfrom the git repository \"origin\", but no such git repository existed, and \nthus it says:\n\n\tfatal: 'origin': unable to chdir or not a git archive\n\nIn fact, the remote name you added seems to be \"root-etc\", juding from \nyour config file (which I've recreated here by looking at your \"git \nconfig -l\" output - things like whitespace may be off):\n\n\t[core]\n\t\trepositoryformatversion=0\n\t\tfilemode=true\n\t\tbare=false\n\t\tlogallrefupdates=true\n\n\t[gui]\n\t\tgeometry=811x591+781+0 107 172\n\n\t[remote \"root-etc\"]\n\t\turl=/root/git/etc\n\t\tfetch=+refs/heads/*:refs/remotes/root-etc/*\n\n> So, I tried removing the remote tracking branches:\n> \n> git branch -d -r root-etc/master\n> \n> But that failed with:\n> \n> error: remote branch 'root-etc/master' not found.\n\nThe easiest way to remove the remote is _literally_ by just editing the \n\".git/config\" file. It's not magic, and the syntax really is as trivial as \nit looks, and it's perfectly ok to just fire up an editor and fix it up. \n\nIn this case, the easiest fix is to not delete that remote entry at all \n(it's a fine entry, afaik), but you have to tell git that your local \n\"master\" branch should track it.  You do that by just adding\n\n\t[branch \"master\"]\n\t\tremote = root-etc\n\t\tmerge = refs/heads/master\n\nwhich tells git that when you are on the \"master\" branch, and do a \"git \nfetch\", it should fetch from that \"root-etc\" remote (and if you doa \n\"pull\", which implies also merging, it should merge the \n\"refs/heads/master\" branch from that remote into your local master).\n\n> So I then tried recreating the remote reference:\n> \n> git remote add root-etc /root/git/etc/.git\n>\n> But that failed with:\n> \n> remote root-etc already exists\n\nRight. It already does, because you already have it, and your previous add \nalready worked. The only issue is that since you didn't tell that your \ncurrent branch should be hooked up with that particular remote, so git \nended up using the default (which is called \"origin\", not \"root-etc\").\n\n\t\tLinus\n"},{"id":"44103","messageId":"8A00BB77B01133479F4A56D932A113220290715F@EX-401.mail.navisite.com","threadId":"8452","inReplyTo":"alpine.LFD.0.98.0706051308090.4921@woody.linux-foundation.org","subject":"RE: How to remove invalid remote repository","fromName":"Matt Seitz","fromEmail":"seitz@neopathnetworks.com","sentAt":"2007-06-05T20:57:08Z","receivedAt":"2007-06-05T20:57:08Z","isPatch":false,"sender":{"key":"seitz@neopathnetworks.com","avatar":null},"body":"From: Linus Torvalds [mailto:torvalds@linux-foundation.org] \n> Well, this is because you apparently didn't call the remote \n> \"origin\", but something else. So when you do\n> \n> \tgit fetch\n> \n> without giving any remote name at all, git will *default* to \n> using \"origin\" as a remote,\n\nAh, I see now.  I misread that section of the \"Git User's Manual\".\nUsing \n\ngit fetch root-etc\n\nworked fine.\n\nSorry to have bothered everyone with my error.\n"}]}