We used Visual Studio 2013 and Git source control to connect Visual Studio Online, see previous blog here.
When we tried to Sync master branch, we got the following error message:
An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error).
An error occurred while sending the request.
We tried to search a solution from internet but we did not get any, There were some users got the same error message like us, but all them did not get good answer or an exact reason and a good solution.
We found the reason ourselves finally.
When we pushed our local existing project to Visual Studio Online, though we did create a local repository and committed our code changing, but Visual Studio 2013 did not give any message to tell us to change Git default repository location. The default repository location is C:\Users\yourname\Source\Repos.
We must change the default repository location to our project directory which we push the project to Visual Studio Online from.
For changing the default repository location, following the following steps:
1: Go to Team Explorer home screen. click Settings button:
2: Click Git Settings:
3: Change Default Repository Location to your current project folder, for example: change to D:\Mycode\MyTestGitProject
After you changed, now try Sync repository, it should work then.