Search code examples
gitgithubvirtualboxshared-directory

Using a git repo on a directory shared between a VM and a host causes problems


I have an ubuntu VM on an osx host. I have a shared drive from the host with a git clone of a project from github. I would like to be able to perform git commands both on the host and the guest, on the same shared directory

I primarily edit and commit from the osx host and primarily compile and run from the ubuntu guest, which works fine. But occasionally I would like to run a git command from the guest.

This causes problems though. If I run git status on the ubuntu host, git acts like all of the files are untracked.

I did a git clone on a separate dir on the host and compared .git/config between that and the .git/config on the shared drive and they are the same.

Is there any way to make this work?


Solution

  • I found if I umounted the share and remounted it with the same UID/GID as my mac user it works. First I changed my UID on ubuntu to match my user on mac, then I mounted it with:

    sudo mount -t vboxsf myshare /media/sf_myshare/ -o rw,uid=501,gid=20
    

    git is now happy.