Re: `git worktree list` when bare repository is named `.git`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> The actual bare repository can be the directory, in a .git directory,
> or in any other directory (as long as it has a .git file that points
> to the actual bare repository). The directory will still be considered a
> bare repository.

Perhaps your example got scrambled, but I can't quite reproduce it:

$ mkdir -p repo/.bare
$ cd repo/.bare
$ git init --bare
Initialized empty Git repository in /private/tmp/repo/.bare/
$ git worktree list
/private/tmp/repo/.bare  (bare)
$ cd ..
$ git worktree list
fatal: not a git repository (or any of the parent directories): .git
$ echo 'gitdir: .bare' >.git
$ git worktree list
/private/tmp/repo/.bare  (bare)

It seems like the $GIT_DIR is shown in the worktree list here, and when I add
a `.git` file pointing to `.bare` manually, that doesn't get listed. (Which I
suppose makes sense, because it's not a `git-worktree(1)` worktree, but still
seems a little bit odd?)

> For the purposes of `git worktree list`, the `.git` suffix **should not** be
> shown. You should never try to use `git worktree list` to get the actual path
> of the repository, the docs give the following warning:
>
>     See gitrepository-layout[5] for more information. The rule of thumb is do
>     not make any assumption about whether a path belongs to $GIT_DIR or
>     $GIT_COMMON_DIR when you need to directly access something inside $GIT_DIR.
>     Use git rev-parse --git-path to get the final path.

I understood this note to be talking about paths _within_ the `$GIT_DIR` or
`$GIT_COMMON_DIR` itself; I see no reason why `git worktree list` wouldn't list
a bare repository _consistently_ as either the `$GIT_DIR` or the parent of the
`$GIT_DIR`.

What I'd like to do is get the path of the worktree so that I can move it. `git
worktree list` gives me this information _except_ for bare repositories in
directories named `.git`. I'm happy to have a special case for this, but I'd
like to understand the principle here.

Maybe I'm just not supposed to name a bare repository `.git`? The
`gitrepository-layout(5)` page does seem to imply this is mutually exclusive
with bare repositories:

> A Git repository comes in two different flavours:
>
> •    a .git directory at the root of the working tree;
>
> •    a <project>.git directory that is a bare repository (i.e. without its
>      own working tree), that is typically used for exchanging histories with
>      others by pushing into it and fetching from it.

Thanks for your help!





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux