I created a folder on OneDrive called My files>GitHub>MedAverter. I note it’s url:
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:
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:
valid: is this a git repository?
What am I missing?
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.
Answered By – bk2204