I mistakenly entered the wrong directory name for "git remote add" (I
entered the working tree directory name instead of the ".git" directory
name).
So "git fetch" fails with:
fatal: 'origin': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
Cannot get the repository state from origin
So, I tried removing the remote tracking branches:
git branch -d -r root-etc/master
But that failed with:
error: remote branch 'root-etc/master' not found.
So I then tried recreating the remote reference:
git remote add root-etc /root/git/etc/.git
But that failed with:
remote root-etc already exists
So, how can I remove the incorrect remote repository reference and
replace it with a correct one?
[root@demo5 etc]# git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
gui.geometry=811x591+781+0 107 172
remote.root-etc.url=/root/git/etc
remote.root-etc.fetch=+refs/heads/*:refs/remotes/root-etc/*
[root@demo5 etc]# git version
git version 1.5.0.7
On Tue, Jun 05, 2007 at 14:41:04 -0500, Matt Seitz wrote:
I mistakenly entered the wrong directory name for "git remote add" (I
entered the working tree directory name instead of the ".git" directory
name).
There does not seem to be any 'git remote remove'. So you'll do it by
changing the config. Either with git-config, or by editing .git/config (it
*IS* meant to be hand-edited).
[...]
So, how can I remove the incorrect remote repository reference and
replace it with a correct one?
[root@demo5 etc]# git config -l
[...]
remote.root-etc.url=/root/git/etc
^^^^^^^^^^^^^
This is the URL. You can simply fix it either with
git-config remote.root-etc.url /root/git/etc/.git
or by editing
.git/config
remote.root-etc.fetch=+refs/heads/*:refs/remotes/root-etc/*
The section corresponding to these two entries in .git/config looks like:
[remote "root-etc"]
url = /root/git/etc
fetch = +refs/heads/*:refs/remotes/root-etc/*
You can tweak it to your heart's content. The documentation is in man pages
of git-config and git-fetch.
--
Jan 'Bulb' Hudec [off-list ref]
On Tue, 5 Jun 2007, Matt Seitz wrote:
I mistakenly entered the wrong directory name for "git remote add" (I
entered the working tree directory name instead of the ".git" directory
name).
Now, that should be fine. You don't have to add the .git name, git will
figure it out on its own.
So "git fetch" fails with:
fatal: 'origin': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
Well, this is because you apparently didn't call the remote "origin", but
something else. So when you do
git fetch
without giving any remote name at all, git will *default* to using
"origin" as a remote, but since no such remote name exists, it will try to
use that remote as a pathname (which is admittedly a bit silly, but git
doesn't know that), and so what happened was that it was trying to fetch
from the git repository "origin", but no such git repository existed, and
thus it says:
fatal: 'origin': unable to chdir or not a git archive
In fact, the remote name you added seems to be "root-etc", juding from
your config file (which I've recreated here by looking at your "git
config -l" output - things like whitespace may be off):
[core]
repositoryformatversion=0
filemode=true
bare=false
logallrefupdates=true
[gui]
geometry=811x591+781+0 107 172
[remote "root-etc"]
url=/root/git/etc
fetch=+refs/heads/*:refs/remotes/root-etc/*
So, I tried removing the remote tracking branches:
git branch -d -r root-etc/master
But that failed with:
error: remote branch 'root-etc/master' not found.
The easiest way to remove the remote is _literally_ by just editing the
".git/config" file. It's not magic, and the syntax really is as trivial as
it looks, and it's perfectly ok to just fire up an editor and fix it up.
In this case, the easiest fix is to not delete that remote entry at all
(it's a fine entry, afaik), but you have to tell git that your local
"master" branch should track it. You do that by just adding
[branch "master"]
remote = root-etc
merge = refs/heads/master
which tells git that when you are on the "master" branch, and do a "git
fetch", it should fetch from that "root-etc" remote (and if you doa
"pull", which implies also merging, it should merge the
"refs/heads/master" branch from that remote into your local master).
So I then tried recreating the remote reference:
git remote add root-etc /root/git/etc/.git
But that failed with:
remote root-etc already exists
Right. It already does, because you already have it, and your previous add
already worked. The only issue is that since you didn't tell that your
current branch should be hooked up with that particular remote, so git
ended up using the default (which is called "origin", not "root-etc").
Linus
From: Linus Torvalds [mailto:torvalds@linux-foundation.org]
Well, this is because you apparently didn't call the remote
"origin", but something else. So when you do
git fetch
without giving any remote name at all, git will *default* to
using "origin" as a remote,
Ah, I see now. I misread that section of the "Git User's Manual".
Using
git fetch root-etc
worked fine.
Sorry to have bothered everyone with my error.