Search code examples
phpgitgithubonedrive

how to setup a OneDrive folder as a git repo?


I created a folder on OneDrive called My files>GitHub>MedAverter. I note it's url:

https://onedrive.live.com/?id=CC97284F14BADC27%211034825&cid=CC97284F14BADC27

I downloaded GitHub Desktop and set the Current repository to the newly created MedAverter folder.

I navigate to my local code folder in git bash: /c/users/greg/LaravelProjects/MedAverter

I enter the following command:

git remote set-url origin https://onedrive.live.com/?id=CC97284F14BADC27%211034824&cid=CC97284F14BADC27

To check it is correct, I do:

git remote -v

here is the output:

origin  https://onedrive.live.com/?id=CC97284F14BADC27%211034824 (fetch)  
origin  https://onedrive.live.com/?id=CC97284F14BADC27%211034824 (push)

Note that it is shorter than the original?

I do a git status and see a bunch of unstaged files, as expected. I stage them with

git add .

Then I commit the files with:

git commit -m "first commit"

Then push the files with:

git push -u origin master

But get error:

fatal: https://onedrive.live.com/?id=CC97284F14BADC27%211034824/info/refs not valid: is this a git repository?

What am I missing?


Solution

  • In order to use an HTTP remote for Git, it either has to support the smart protocol, which requires a special server endpoint, or it has to support WebDAV, which is commonly referred to as the dumb protocol. In addition, the remote cannot use query parameters, since Git will not handle them.

    If you want to use OneDrive with WebDAV, you'll need some way to get the initial repository structure up to the server, which will likely involve using a standard WebDAV client to upload a directory created with git init --bare.

    As mentioned, you'll also need a WebDAV URL that doesn't include any query parameters; if OneDrive can't provide that, then you'd need to use a different provider.

    Do note that you should not use OneDrive as a syncing tool for your Git repository across machines because doing so can cause corruption.