threads / discuss / 36449

the ".git" folder

Subject: the ".git" folder

## tl;dr

4 messages between Apr 20, 2014 and Apr 20, 2014.

replies: 3people: 4as markdown or json

Miller, Hugh· Apr 20, 2014, 09:13 UTC · lore
Dear Community,
Is there any way to use .git (e.g., a different set of "client" commands) that allows the .git folder to be placed in a location away from the actual files being versioned ? For example, can one set environment variables that let the software know where the .git folder is ?
Reason for asking - the files being versioned are acted on other applications that know nothing about git, so presence of .git in the file directory may cause problems.
Thanks,
Hugh Miller
Duy Nguyen· Apr 20, 2014, 09:49 UTC · re: Miller, Hugh · lore

Re: the ".git" folder

On Sun, Apr 20, 2014 at 4:13 PM, Miller, Hugh <HughMiller@chevron.com> wrote:
> Dear Community,
>
> Is there any way to use .git (e.g., a different set of "client" commands) that allows the .git folder to be placed in a location away from the actual files being versioned ? For example, can one set environment variables that let the software know where the .git folder is ?
Try

git --git-dir=<new .git location> --work-tree=<top work tree location> <some command>

The reason of two arguments instead of one is because .git is also used to mark top work tree location, which is now lost after you move .git elsewhere. You could also set environment variables GIT_DIR and GIT_WORK_TREE, which have the same effect. "man git" for details.

-- 
Duy
Kevin· Apr 20, 2014, 12:58 UTC · re: Duy Nguyen · lore

Re: the ".git" folder

Another way, which wouldn't require environment variables or extra parameters for each command is moving the .git directory, and replace it with a file called .git, which has the path to the actual .git directory.

Git submodules use this feature too.
On Sun, Apr 20, 2014 at 11:49 AM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 20 quoted lines
> On Sun, Apr 20, 2014 at 4:13 PM, Miller, Hugh <HughMiller@chevron.com> wrote:
>> Dear Community,
>>
>> Is there any way to use .git (e.g., a different set of "client" commands) that allows the .git folder to be placed in a location away from the actual files being versioned ? For example, can one set environment variables that let the software know where the .git folder is ?
>
> Try
>
> git --git-dir=<new .git location> --work-tree=<top work tree location>
> <some command>
>
> The reason of two arguments instead of one is because .git is also
> used to mark top work tree location, which is now lost after you move
> .git elsewhere. You could also set environment variables GIT_DIR and
> GIT_WORK_TREE, which have the same effect. "man git" for details.
> --
> Duy
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Junio C Hamano· Apr 20, 2014, 22:13 UTC · re: Duy Nguyen · lore

Re: the ".git" folder

Duy Nguyen <pclouds@gmail.com> writes:
Show 14 quoted lines
> On Sun, Apr 20, 2014 at 4:13 PM, Miller, Hugh <HughMiller@chevron.com> wrote:
>> Dear Community,
>>
>> Is there any way to use .git (e.g., a different set of "client" commands) that allows the .git folder to be placed in a location away from the actual files being versioned ? For example, can one set environment variables that let the software know where the .git folder is ?
>
> Try
>
> git --git-dir=<new .git location> --work-tree=<top work tree location>
> <some command>
>
> The reason of two arguments instead of one is because .git is also
> used to mark top work tree location, which is now lost after you move
> .git elsewhere. You could also set environment variables GIT_DIR and
> GIT_WORK_TREE, which have the same effect. "man git" for details.

Depending on the true reason why such a split layout is desired, the answer might be the textual .git (aka "gitfile: there") that is used by the submodule folks via "clone --separate-git-dir".

← back to recent threads