# .git ignored regardless of --git-dir value

4 messages from 2011-11-18 to 2011-11-18. Participants: Shawn Ferris, Junio C Hamano.
Thread: https://gitlist.dev/t/28976

## Shawn Ferris, 2011-11-18 20:56

Subject: .git ignored regardless of --git-dir value
Message-ID: <CAC2kKA_PZNDg_dPjWXKeFU4ZVpMas3PubZfSgTnfCfVPuNPdsA@mail.gmail.com>
URL: https://gitlist.dev/e/CAC2kKA_PZNDg_dPjWXKeFU4ZVpMas3PubZfSgTnfCfVPuNPdsA%40mail.gmail.com

```
Hi All --

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/

$ mkdir .git
$ touch .git/filea

$ git --git-dir=.foo --work-tree=. add .

$ git --git-dir=.foo --work-tree=. status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#    new file:   .foo/HEAD
#    new file:   .foo/config
#    new file:   .foo/description
#    new file:   .foo/hooks/applypatch-msg.sample
#    new file:   .foo/hooks/commit-msg.sample
#    new file:   .foo/hooks/post-update.sample
#    new file:   .foo/hooks/pre-applypatch.sample
#    new file:   .foo/hooks/pre-commit.sample
#    new file:   .foo/hooks/pre-rebase.sample
#    new file:   .foo/hooks/prepare-commit-msg.sample
#    new file:   .foo/hooks/update.sample
#    new file:   .foo/index.lock
#    new file:   .foo/info/exclude
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#    deleted:    .foo/index.lock
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    .foo/index
#    .foo/objects/

Notice that .foo was added, but .git was ignored. I would have
expected .foo to be ignored and .git to be added? (right, wrong or
indifferent..)

Thanks for any info!

Shawn

```

## Junio C Hamano, 2011-11-18 21:26

Subject: Re: .git ignored regardless of --git-dir value
Message-ID: <7vsjlljf57.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vsjlljf57.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAC2kKA_PZNDg_dPjWXKeFU4ZVpMas3PubZfSgTnfCfVPuNPdsA@mail.gmail.com>

```
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. 
 ...

```

## Junio C Hamano, 2011-11-18 22:47

Subject: Re: .git ignored regardless of --git-dir value
Message-ID: <7v7h2xjbf4.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7h2xjbf4.fsf%40alter.siamese.dyndns.org
In-Reply-To: <7vsjlljf57.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> 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.

```

## Shawn Ferris, 2011-11-18 23:44

Subject: Re: .git ignored regardless of --git-dir value
Message-ID: <CAC2kKA-E4KstQCGV=gMJHFdUdzM0boc7SmZNzvSh9_OQWvHcdQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAC2kKA-E4KstQCGV%3DgMJHFdUdzM0boc7SmZNzvSh9_OQWvHcdQ%40mail.gmail.com
In-Reply-To: <7v7h2xjbf4.fsf@alter.siamese.dyndns.org>

```
On Fri, Nov 18, 2011 at 3:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:

>>
>> 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

I'm extremely green to git, so please forgive if this is obvious, but,
could I indulge and ask what a sample use case of that would be?
(since it's not intended for what I assumed it was) And, if the
behavior I expected was possible, simply, with perhaps a separate
option, what is the likelihood a patch would be accepted? (Or am I
just talking nonsense and should just go away) ;D

Thanks Again!

Shawn

```
