Error publishing master branch to GitHub from VS.NET

There is a fix for this:

Go to your command prompt and change to your solution directory. From there you should be able to run git commands. You may have to install git if you haven't already Run 'git pull origin master'. This should merge your GitHub repo with your local repo. That's all we have to do from the command prompt. Now go back to Visual Studio

You may get some conflicts, if you do you will have to resolve these and commit locally again. Visual Studio will tell you if there are any conflicts. Once any conflicts are resolved, click on the 'master' link near the top of the pane. It should give you a dropdown with an item called 'manage branches'. Click it. You should see a branch called 'master' under the heading 'Unpublished Branches' Right click on master and click on 'Publish Branch' Now you can click on the 'unsynced changes' link again and you will see that the 'Sync' button is not greyed out anymore Click on Sync and you're done!

Source & credit: http://zanemayo.com/using_git_and_github_with_visual_studio.html


VS 2013 will initialize the GIT repository when your first commit with sync. So, simple solution is to delete the GIT repository and recreate it without initialize option.

enter image description here


I experienced this problem in Visual Studio 2015 and this is how i got it fixed.

  1. Connect to your local git repository
  2. Open Branch
  3. Right Click On the master branch
  4. Select Open Command Prompt
  5. Run git pull origin master (This command will pull changes from the origin remote, master branch and merge them to the local checked-out branch.)
  6. Publish Your Repository .

Since I had just created the repository and there were no users, the solution was to delete the repository from Github (under 'Settings' menu) and create it again (once deleted I could use the same name). The trick is to not initialize the repository from GitHub - allow VS.NET to do this on 1st sync. Now it works wonderfully from VS.NET.

If I would not have deleted the repository, I would of had to use some external tools to either rename the local repository, or use sync from another tool (like TortoiseGit) that allows forcing to overwrite the branch on sync. It did not appear there was anything native to VS.NET that would allow this to occur.