Search code examples
gitfileshare

Git push error "does not appear to be a git repository" with fileshare


This seems like it should be simple but I just can't get this to work and I have searched everywhere but I can't seem to find an answer using a fileshare. I am getting an error when I push a local repository to a fileshare on a network drive. Here is what I have done:

//Create The repository:
cd H:/
git init --bare --shared=group test.git
//Have also tried git init --bare test.git

Then I create a local repository:

cd MyDocuments/Test
git init
git add .
git commit -m "Initial Commit"
git remote add origin 'H:/test.git"
//Have also tried (among many others):
git remote add origin 'file:///fileshare/test.git'

I then get this error:

$git push origin master
fatal: '\fileshare\test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

What am I doing wrong here? Thanks in advance.


Solution

  • As I commented, this would work:

    git remote add origin H:/test.git
    

    For path with spaces, you can try various escape schemes:

    git remote add origin H:/path_with\ spaces/test.git
    git remote add origin "H:/path_with spaces/test.git" <===
    git remote add origin H:/path_with^ spaces/test.git
    

    Or use the same solution as in "GIT clone repo across local file system":

    git remote add origin file://"H:/path_with spaces/test.git"