Skip to content

Support for repos with separate --git-dir / --work-tree (the "bare repo dotfiles" pattern) #2662

Description

@LeBinhAn

Hi! First off, thanks for all the work on this tool — I use it daily and it's made my git workflow a lot smoother.

I wanted to flag a use case that currently isn't detected as a repo, in case it's something you'd consider supporting.

The setup

A pretty popular way to manage dotfiles is to keep the actual git data in one folder, but treat your home directory as the working tree, like this:

git clone --bare <repo-url> "$HOME/.dotfiles"
alias dotfiles='/usr/bin/git --git-dir="$HOME/.dotfiles" --work-tree="$HOME"'

So $HOME/.dotfiles holds all the git metadata, and $HOME itself is the working tree — there's no .git folder inside $HOME at all. The two are linked only through --git-dir / --work-tree (or core.worktree in the bare repo's config).

Why it's not picked up

I think the client looks for a .git folder/file when scanning for repos, which makes total sense for the common case, but it means this pattern gets missed since there's nothing in $HOME to find, and $HOME/.dotfiles on its own just looks like a bare repo.

What would help

  • A way to manually add a repo by specifying the git-dir and work-tree as separate paths, rather than requiring one folder with .git inside.
  • If a bare repo has core.worktree set in its config, using that as the working tree instead of treating it as bare.

No worries if this is too niche to prioritize — just thought I'd share it in case it's a quick win or useful for others doing the same dotfiles trick. Happy to test anything or provide more details if helpful. Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions