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

Re: .git ignored regardless of --git-dir value

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2011, 22:47 UTC
Message-ID
<7v7h2xjbf4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vsjlljf57.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 19 quoted lines
> Shawn Ferris <shawn.ferris@gmail.com> writes:
>
>> Is it expected behavior to have the .git directory ignored, even after
>> specifying an alternate location with --git-dir? For example:
>>
>> $ git --git-dir=.foo init
>> Initialized empty Git repository in /home/sferris/work/t/.foo/
>
> GIT_DIR and --git-dir are meant to refer to a different .git dir (or a
> bare-looking repository) located elsewhere, and not for a random pathname
> like ".foo". No matter what, ".git/" anywhere is ignored from very early
> days of Git, as Linus himself writes in the source, e.g. 8695c8b (Add
> "show-files" command to show the list of managed (or non-managed) files.,
> 2005-04-11):
>
>  ...
>  * Also, we currently ignore all names starting with a dot.
>  * That likely will not change. 
>  ...

Sorry, but the above quote is wrong. The correct one is from 453ec4b (libify git-ls-files directory traversal, 2006-05-16), and survives to this day in dir.c:

 ...
 * Read a directory tree. We currently ignore anything but
 * directories, regular files and symlinks. That's because git
 * doesn't handle them at all yet. Maybe that will change some
 * day.
 *
 * Also, we ignore the name ".git" (even if it is not a directory).
 * That likely will not change.
 ...

In other words, originally we ignored all names starting with a dot and declared that likely will not change, but then loosened the rule to let people manage their .bashrc and friends. But ".git" is still special, and that likely will not change.

Previous: Junio C HamanoNext: Shawn Ferris
Message 3 of 4 in “.git ignored regardless of --git-dir value”
  1. Shawn FerrisNov 18, 2011
  2. Junio C HamanoNov 18, 2011
  3. Junio C HamanoNov 18, 2011
  4. Shawn FerrisNov 18, 2011

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.