Skip to content

Git worktree not supported by Repository object #1225

Description

@jjcole

It seems like "git worktree" introduced in Git 2.5 is not supported by the library. If I try to create a Repository object with my worktree directory, or with the file path directly to the ".git" file, it says it's not a valid Git repository.

For example, I have C:\Code\Main and I use "git worktree" to create a worktree at C:\Code\Fix. I am not able to create a Repository object if I pass in either "C:\Code\Fix" or "C:\Code\Fix.git". It also doesn't work if I pull the gitdir out of the .git file (C:\Code\Main\worktrees\Fix) and pass that into the Repository constructor. (Git Extensions correctly handles the worktree so I don't believe there's any other issue at play.)

Apologies if this is covered somewhere else or if I'm just doing something wrong, Google search wasn't very helpful and the term worktree didn't bring up anything here in Issues.

I tried working around by setting IndexPath and WorkingDirectoryPath in RepositoryOptions, but it still uses the current HEAD of the original repo at C:\Code\Main instead of the one in C:\Code\Fix.

More details on git worktree:
https://git-scm.com/docs/git-worktree
https://github.com/blog/2042-git-2-5-including-multiple-worktrees-and-triangular-workflows

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