Jazimov
Jazimov

Reputation: 13292

"Failed to push the branch to the remote repository" Error

When trying to push/sync local code to a remote TFS 2015 server, I am getting the error "Failed to push the branch to the remote repository". How do I go about diagnosing this?

Upvotes: 0

Views: 6861

Answers (1)

Jazimov
Jazimov

Reputation: 13292

Check the Visual Studio Output window and look for details there. In many cases you will see that a repository was "not found" or that it "does not appear to be a git repository". If that's the case, one way to resolve the problem is to go to the TFS 2015 server and access the administration pages there.

To do that, log on to the TFS server then launch the Internet Explorer/Edge web browser and navigate to the main TFS page (substitute the IP address for the workstation and specify port 8080):

http://#.#.#.#:8080/tfs

You then should see the TFS Team Foundation Server page. Click the Administer link and you will be taken to the Administer your server page. There, look for your collection on the left pane and click it.

If there is an existing team project that you are trying to push/sync to from Visual Studio, you will see it listed under the Collection name on the left pane (you might have to expand the collection to see its items). Take note of the Collection name.

Click the View the collection administration page link. If you see your project there, take note of its name. Otherwise, click New team project to create a new team project. Take note of the project name you specify.

Once your team project exists, you should be able to fix the error you received in Visual Studio. To do that, go to the Team Explorer window and click the Home icon at the top. Then click Settings. There you will see a link for Global Settings and Repository Settings. Click Repository Settings.

Look for the Remotes section. You should see a Fetch and Push Url listed. Click Edit and change the Fetch Url (the Push will adjust if the Push matches fetch checkbox is checked). Then change it to this format:

http://#.#.#.#:8080/tfs/{collection_name}/_.git/{project_name}

Note that the collection_name and project_name should match the collection name and project name you identified in the steps above. Click Save.

Now click the Team Explorer Home icon again, click Sync, and click Push under Outgoing Commits. If your Url was incorrect or your TFS project was not created on the TFS server, you no longer should see an error message and your Push operation should succeed without errors.

Upvotes: 1

Related Questions