I have a local GIT repo with commits but so far unsynced. I created it as per https://stackoverflow.com/a/20004092/586754 which basically results in the local part of the repo with no remote/origin.
I don't have a (company) GIT server but a Onedrive for Business account that seems perfect to at least backup the repo in case the dog eats the machine. (Plan for later is to migrate to comany VCS, which is SVN, once things have stabilized.)
I know that GIT can sync to a file system, but.. how to do it?
Since I already entered some wrong data as a remote repo in Visual Studio (it asked when I went for the "Sync" option, complained, and now all options are greyed out under "Sync"), how do I change this? Only via the command line like
git remote set-url origin "C:\Users\Test\OneDrive for Business\Andreas\code\project1"
What is the correct GIT URL for a network share and also for a local share? (In my case, I am most interested in the local Windows share, since I expect Onedrive to be responsible for the backup.)
I have an empty folder as a remote right now (I created full path including "project1") and also am getting errors via command line:
git push --set-upstream origin master
fatal: 'C:\Users\Test\OneDrive for Business\Andreas\code\project1' does not appear to be a git repository
fatal: Could not read from remote repository.
Is anything else needed for initial push? Sor far, I have only used bitbucket/github, where I explicitly created a repo beforehand via web interface.
After some more searching..
I had following mistakes:
Git Repo needs to be initialized:
git init --bare project1.git
Correct folder naming, also
So, if you start from scratch, here is the procedure on Windows (well, it is Visual Studio integration after all..):
cd into that location and execute (for more info and how to cd into network path, see http://elegantcode.com/2011/06/18/git-on-windows-creating-a-network-shared-central-repository/ )
cd ""C:\Users\Test\OneDrive for Business\Andreas\code\project1"
git init --bare project1.git
continue on the command line, in the folder of the local git repo/source files:
git remote set-url origin "file:///C:\Users\Test\OneDrive for Business\Andreas\code\project1\project1.git"
will set the correct remote/origin (this we cannot do in Visual Studio, checked with VS2015)
tell git what branches to use
git push --set-upstream origin master
Now "sync"ing in Visual Studio should work, you can also do it from commandline (push only) with:
git push
As for correct URLs on Windows, for a local folder, it is
file:///C:\Users\Test\OneDrive for Business\Andreas\code\project1\project1.git
For a network share, you can either map it to a local drive and use that (same as local folder) or
file:////remoteServer/git/Share/Folder/Path/project1.git
or
file://\\MyWorkPC\folder\project1.git
(see also https://stackoverflow.com/a/2520121/586754 )
I worked on this for about an hour. Pretty frustrating. In the end, here is what I had to do.
I have a mapped network drive that I'm syncing to just as an added backup. I imagine OneDrive is similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With