Vscode-gitlens: Git Lens does not work with git work trees.

Created on 13 Mar 2020  路  4Comments  路  Source: eamodio/vscode-gitlens


  • GitLens Version: 10.2.1
  • VSCode Version: 1.42.1
  • OS Version: Win 10

Steps to Reproduce:

  1. cd
  2. git worktree add ../foo
  3. Open foo in vscode

git lens functionality won't be available in foo, git works fine in the console though.

I guess it's not that surprising but it would be nice if it would work and I didn't expect it to cause issues.

needs more info potential bug

Most helpful comment

While writing up more details I found the issue. It's not really related to git lens but to msys git versus git on windows

What doesn't work?

The folder was not recognized as git repository.

In a regular git tree everything worked:

grafik

If I open a worktree in VSCode it's not recognized as a git repo at all.

grafik

I usually use a msys shell there it works fine:

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git --version
git version 2.25.1

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git status
On branch ...
Your branch is ahead of '.../...' by 7 commits.
  (use "git push" to publish your local commits)

However it doesn't work for the windows version of git. Executed in git bash:

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git --version
git version 2.26.0.windows.1

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git status
fatal: not a git repository: /e/ghc/.git/worktrees/ghc_wio_settings

Turns out the issue is I added the worktree under msys which used a linux-style path: /e/ghc/.git/worktrees/ghc_wio_settings

Rewriting it to a windows-style path by hand fixed the issue.

$ cat .git
gitdir: E:\\ghc\\.git\\worktrees\\ghc_wio_settings

Now everything works as expected. I hope this is useful if someone runs into the same issue in the future.

All 4 comments

@AndreasPK What doesn't work? I've tried it and everything I've tried seems to work for me.

While writing up more details I found the issue. It's not really related to git lens but to msys git versus git on windows

What doesn't work?

The folder was not recognized as git repository.

In a regular git tree everything worked:

grafik

If I open a worktree in VSCode it's not recognized as a git repo at all.

grafik

I usually use a msys shell there it works fine:

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git --version
git version 2.25.1

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git status
On branch ...
Your branch is ahead of '.../...' by 7 commits.
  (use "git push" to publish your local commits)

However it doesn't work for the windows version of git. Executed in git bash:

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git --version
git version 2.26.0.windows.1

Andi@Horzube MINGW64 /e/ghc_wio_settings
$ git status
fatal: not a git repository: /e/ghc/.git/worktrees/ghc_wio_settings

Turns out the issue is I added the worktree under msys which used a linux-style path: /e/ghc/.git/worktrees/ghc_wio_settings

Rewriting it to a windows-style path by hand fixed the issue.

$ cat .git
gitdir: E:\\ghc\\.git\\worktrees\\ghc_wio_settings

Now everything works as expected. I hope this is useful if someone runs into the same issue in the future.

Similar problem with the Remote:SSH plugin. Solved by changing gitdir to use a relative path.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings