Tuesday, May 21, 2019

Using Git and Git Bash on a network drive

I've run into two problems lately with using Git with a network drive.

First, I use RStudio with R projects that contain a Git repository.  Some of these projects are stored on a network drive.  This is a shared drive that has a sort of odd file path (as described in this question).  As I wasn't sure how to map a network ("UNC path") to a folder (the suggested solution), I poked around to see what else might get it to work.

I ended up running RStudio as administrator.  This allowed me to set the project as having Git (before, when running as non-administrator, this gave a useless error message saying "function error").  Once I set the global options to project having version control, RStudio created a new .Rproj file, restarted itself, and then the Git tab appeared in RStudio.  When I opened the .RProj file again I did not need to run as administrator.

Second, I wanted to run Git in a folder located on a network drive by right-clicking in the repository folder on "Git Bash".   This brings up Git Bash, but it says "CMD.EXE was started with the above path as the current directory.  UNC paths are not supported.  Defaulting to Windows directory."  I found that I could cd there, but I had to copy the file path from the Windows file explorer window, and then change all the slashes to forward slashes (/) from the Windows default back slashes (\).