Reputation: 779
I have just created a new project in VS2013 and added it to source control, choosing the Git option. This has created the expected hidden .git folder in the root of the solution and the project now shows symbols indicating it is under source control.
I am now wanting to push the whole new solution to another directory, which will eventually become the shared repo. I got a helpful message in VS, telling me that, to publish my latest commits to a remote repo, I needed to Sync. I selected this and got a message saying that 'Visual Studio cannot (yet) publish to a non-bare repo.'
I had already externally run git init
in the target repo, which I thought would be accepted as a bare empty repo by VS, but it seems not to be the case. That is a side issue really. My main problem is that the option to Sync is now greyed-out in VS, even though it claimed that the Sync failed. Nothing I do seems to get the option back.
Can anyone spot what I am doing wrong and hopefully tell me how to 'fix' this? Also, if anyone knows of any good documentation specifically dealing with how Git works from within VS, I'd love to hear about it.
Upvotes: 1
Views: 445
Reputation: 13917
When you're setting up your remote repository, you should create it using the --bare
flag.
git init --bare <directory>
Atlassian has a small explanation here on the git init options, which would be good to read, but I would assume that Visual Studio just sees the remote as another repository and doesn't understand how to push to it when not created as bare.
From the Atlassian article:
Think of
--bare
as a way to mark a repository as a storage facility, opposed to a development environment. This means that for virtually all Git workflows, the central repository is bare, and developers local repositories are non-bare.
Upvotes: 2