If you do this:
git clone https://github.com/go-git/go-git
cd go-git
git worktree add ../go-git-wt
and then use go-git to open the repo at go-git-wt and call repo.Head()
repo, err := git.PlainOpenWithOptions(dir, &git.PlainOpenOptions{DetectDotGit: true})
...
head, err := repo.Head()
this returns a "reference not found" error. The go-git/.git/worktrees/go-git-wt/HEAD file contains a symbolic ref to something like refs/heads/go-git-wt but that ref is not found under go-git/.git/worktrees/go-git-wt. Instead it is in the primary git dir at go-git/.git/refs/heads/go-git-wt and the go-git library doesn't look in there.
If you do this:
and then use go-git to open the repo at go-git-wt and call
repo.Head()this returns a "reference not found" error. The
go-git/.git/worktrees/go-git-wt/HEADfile contains a symbolic ref to something likerefs/heads/go-git-wtbut that ref is not found undergo-git/.git/worktrees/go-git-wt. Instead it is in the primary git dir atgo-git/.git/refs/heads/go-git-wtand the go-git library doesn't look in there.