Re: How to remove invalid remote repository

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux