Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Git worktrees #21

Closed
ecraig12345 opened this issue Jan 21, 2021 · 1 comment · Fixed by #22
Closed

Doesn't work with Git worktrees #21

ecraig12345 opened this issue Jan 21, 2021 · 1 comment · Fixed by #22

Comments

@ecraig12345
Copy link
Contributor

If I open the root folder of a Git worktree in VS Code, open a file, and try to use any of the commands to copy a link, I get an error The workspace at 'file:///Users/me/git/my-repo-worktree' is not tracked by Git. The commands work fine in the main local copy of the same repo.

Worktrees are implemented with a .git file which points to the the actual directory:

/my-repo-worktree
  .git            file with contents: 
                  gitdir: /(actual path here)/my-repo/.git/worktrees/my-repo-worktree

/my-repo
  .git/
    worktrees/
      my-repo-worktree/
        (normal .git folder stuff)

So this line ought to allow .git to be either a file or directory.
https://github.com/reduckted/vscode-gitweblinks/blob/d7bc2db7102f07032f5af2262bfd83942fdb86c4/src/repository-finder.ts#L64

Then if all you're doing is running git commands, that can be done from the root of the worktree. (Only need to bother with looking in my-repo/.git/worktrees/my-repo-worktree/ if you need to dig into the .git folder contents, which I'd guess isn't needed?)

@reduckted
Copy link
Owner

This is now available in v2.1.0 which has just been published to the marketplace.

Thanks again for the contribution, @ecraig12345! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants