I use OneDrive to sync my personal projects between all the machines I work with (home desktop, notebook and the computer at work). In my home PC, I have a git repository in the following path:
I:\OneDrive\Documents\Projects\MyProject
In my work computer, the OneDrive base location is mapped to a different path, so that folder syncs to:
C:\Users\MyUser\OneDrive\Documents\Projects\MyProject
I use VSCode with git integration and everything works fine in my home computer, but when I open the repo with VSCode in my work computer, it doesn't recognize the repository. If I open the config file inside the .git directory, I can see that worktree is pointing to the absolute path of my home machine:
worktree = I:/OneDrive/Documents/Projects/MyProject
I think git is trying to find this path in my work computer, which doesn't exists (as the OneDrive is mapped to a different location), and so it don't recognize the repository in VSCode.
Is there a way to fix this? Can I make git use relative paths when dealing with the repo location? I tried changing the worktree to ../
but that doesn't seem to work.
Thanks!