Hermios
Hermios

Reputation: 634

Visual studio/GIT : No tracked remote branch

I just configured Visual Studio 2015 with a connection to GitHub. Unfortunately, it doesn't work to track the remote branch. I have 2 projects in the same solution, each has its own repository. For each of them, - I only have one branch (Master) - I checked that the remote branch was set correctly (Push and fetch have the same value). I eventually reset the branches - In Synchronization, only "Fetch" is not greyed out. Clicking on it doesn't synchronize. Under "Incoming Commit" is written "The current branch does not track a remote branch". - When working with Git GUI, it works fine, I can easily fetch and push.

Please ask if you need more information.

Thanks

Niko

Upvotes: 25

Views: 22885

Answers (2)

This Guy
This Guy

Reputation: 634

run this through command prompt in your local repo folder:

git branch --set-upstream-to=origin/master master

That will then enable you to "push" through team explorer in VS

Upvotes: 6

Reg Edit
Reg Edit

Reputation: 6916

The UI doesn't make it very clear that you have to use Publish without adding a remote repo.

If you add a remote first, Publish never becomes available and you get stuck in the "does not track a remote branch" state. I've just had the same trouble in VS2017.

Wrong way:

You might think that before you can sync to a remote, you have to tell Visual Studio about the remote. Don't do that.

enter image description here

enter image description here


Right way:

Instead, hit Sync:

enter image description here

Visual Studio detects that there is no remote configured for the repo, and takes you to the Push dialog:

enter image description here

Press the relevant Publish button, and an input box appears. This is the right place to configure Visual Studio with the URL of the remote repo.

When the remote is added this way, Visual Studio recognizes the status of the remote repo so that it no longer thinks it's untracked. From now on, it enables all the sync/push functionality as expected.

Upvotes: 48

Related Questions