PinkTurtle
PinkTurtle

Reputation: 7041

Is specifiying a work-tree in a .git file supported?

I have this in a .git file :

gitdir: path\to\git-dir

I would like to also add the work-tree dir, something ala

worktree: path\to\work-tree

Is that supported by git ?

Upvotes: 1

Views: 50

Answers (2)

PinkTurtle
PinkTurtle

Reputation: 7041

I have found a solution to my problem [for future ref here : https://rakhesh.com/coding/how-to-move-separate-the-git-folder-out-of-your-working-tree].

A work-tree can be specified [not in a .git file but] in the git folder config file; by adding a worktree line. Easy as that :)

Example git-dir/config file:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
>>  worktree = <path/to/work-tree>

Upvotes: 1

torek
torek

Reputation: 488183

The short answer is no.

The .git file (when there is a .git file) must occupy the top level of the working tree, so if you have a .git file, the directory in which that .git file lives is the working tree. So there's no point in listing the working tree path: it's implied by the fact that you used that path to open the file named .git. This does of course mean that you have to remember the path you used to open the file named .git, which in some circumstances is a bit of a pain point, but that's why the answer is no.

Upvotes: 0

Related Questions