Chris
Chris

Reputation: 845

Visual Studio 2019, v16.7.5: Unable to push to multiple Repositories

I have created a new project in Visual Studio Version 16.7.5. Then I

• Add this project to git source control

• Push the project to GitHub as a new repository

• Go to repository settings

• Add a new remote (local repository initialised with “git init --bare”)

• Try to push to the new remote -> fails with:

Microsoft.TeamFoundation.Git.Contracts.GitRemoteRefNotFoundException

I also tried pushing to the local repository first (works) and then to github (fails). I have proceded this way in over 60 projects and never had a problem so far. Also, pushing to both repositories works with projects that already exist. Does anyone have an idea how to fix this?

Upvotes: 2

Views: 6135

Answers (2)

Big Ian
Big Ian

Reputation: 163

I fixed this by:

  1. Reboot

  2. Open Developer Command Prompt as admin

  3. Execute:

    devenv /resetuserdata

  4. Load Visual Studio

  5. Push

Upvotes: 0

Chris
Chris

Reputation: 845

Found a workaround for my problem:

  • Create empty second repository somewhere in file system using

git init --bare

  • In Visual Studio go to repository settings and add the newly created remote location, save.
  • Right click on project in windows explorer
  • Open Git bash and execute the following git command:

git push [name of repo] master

Once the project has initially been pushed to the second repository like that you can use it normally in Visual Studio and push without getting the error stated in the question.

Upvotes: 1

Related Questions