git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git push to a local directory with no .git in it

From
Junio C Hamano <junkio@cox.net>
Date
Sep 30, 2005, 00:05 UTC
Message-ID
<7v7jcze7xu.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<loom.20050930T011606-58@post.gmane.org>
Richard Curnow <rc@rc0.org.uk> writes:
Show 5 quoted lines
> I get
>
> fatal: /home/richard/homepage/git/mairix.git doesn't appear to be a git directory
>
> presumably because there is no .git in it.
Please don't presume, but dig.
        $ git grep -n 'doesn.t appear to be'
        receive-pack.c:275:		die("%s doesn't appear to be a git directory", dir);
And the lines around there are:
	/* chdir to the directory. If that fails, try appending ".git" */
	if (chdir(dir) < 0) {
		if (chdir(mkpath("%s.git", dir)) < 0)
			die("unable to cd to %s", dir);
	}
	/* If we have a ".git" directory, chdir to it */
	chdir(".git");
	putenv("GIT_DIR=.");
	if (access("objects", X_OK) < 0 || access("refs/heads", X_OK) < 0)
		die("%s doesn't appear to be a git directory", dir);
	write_head_info();

We chdir to mairix.git/, and then try to chdir to .git beneath it _if_ _exists_; we do not care if the second chdir fails. So if you do not have mairix.git/.git, that's OK. We will stay in mairix.git/ directory and then set the GIT_DIR there.

If you do not have mairix.git/objects or mairix.git/refs/heads/ then that's when you get that error message.

	$ cd /home/richard/homepage/git/mairix.git
        $ ls -ld objects refs refs/heads
would tell us more.
        
Previous: Richard CurnowNext: Richard Curnow
Message 2 of 3 in “git push to a local directory with no .git in it”
  1. Richard CurnowSep 29, 2005
  2. Junio C HamanoSep 30, 2005
  3. Richard CurnowSep 30, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.