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

WSL & Worktree issue : Not a git repositiory #1789

Open
OdysseusOperator opened this issue Dec 12, 2024 · 3 comments
Open

WSL & Worktree issue : Not a git repositiory #1789

OdysseusOperator opened this issue Dec 12, 2024 · 3 comments

Comments

@OdysseusOperator
Copy link

Git is set up, just like this: https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-git

I am using WSL Ubuntu 24.04.
Windows and Linux both have Git in Version 2.47.1
This error doesn't appear on Windows, just from WSL.


Steps to reproduce: (Works with all repos i think)
Open Wsl.
make a dir to work in and cd into it.
git clone https://github.com/routerdieb/java11TxtTimebox main
cd main
git worktree add ../test123
cd ..
cd test123
git pull (or git push doesnt matter here)

@OdysseusOperator
Copy link
Author

 git push --set-upstream origin test123
fatal: not a git repository: /mnt/d/code2dash_wsl/main/.git/worktrees/test123

Unhandled Exception: System.InvalidOperationException: StandardError has not been redirected.
   at System.Diagnostics.Process.get_StandardError()
   at GitCredentialManager.ChildProcess.get_StandardError()
   at GitCredentialManager.GitProcess.CreateGitException(ChildProcess git, String message, ITrace2 trace2)
   at GitCredentialManager.GitProcessConfiguration.Enumerate(GitConfigurationLevel level, GitConfigurationEnumerationCallback cb)
   at GitCredentialManager.GitConfigurationExtensions.Enumerate(IGitConfiguration config, GitConfigurationEnumerationCallback cb)
   at GitCredentialManager.Settings.<GetSettingValues>d__6.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at GitCredentialManager.Settings.TryGetSetting(String envarName, String section, String property, String& value)
   at GitCredentialManager.Settings.GetTrace2Settings()
   at GitCredentialManager.Trace2.Initialize(DateTimeOffset startTime)
   at GitCredentialManager.Program.AppMain(Object o)
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)
Username for 'https://github.com':

@becm
Copy link

becm commented Jan 15, 2025

The issue arises due to mixing UNIX and Win32 executable using absolute paths.
The native (Linux) Git creates WSL/*NIX notation (/mnt/d/code2dash_wsl/…).
GCM (or its Git companion) in such a scenario only knows Win32 paths (D:/code2dash_wsl/…).

While the Exception is (just) bad error handling, the underlying issue persists.
You can mitigate this by using a relative path references in /mnt/d/code2dash_wsl/test123/.git:
gitdir: ../main/.git/worktrees/test123
That is also the way Git submodules handle references to their respective Git directory.

The subsequent (forward) resolution to the origin Git directory is also using relative paths
(See contents of /mnt/d/code2dash_wsl/main/.git/worktrees/test123/commondir).
Backward resolution of the worktree folder could still become problematic without further adjustment.
But GCM luckily does not care about that. 😄

@becm
Copy link

becm commented Jan 21, 2025

Starting with Git v2.48 there is now an option to use relative paths when using worktrees.

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

No branches or pull requests

2 participants