Short Version
Remove the appropriate entr(y|ies) under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories
.
Remove HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\General\LastUsedRepository
if it's the same as the repo you are trying to remove.
Background
It seems like Visual Studio tracks all of the git repositories that it has seen. Even if you close the project that was referencing a repository, old entries may still appear in the list.
This problem is not new to Visual Studio:
VS2013 - How do I remove local git repository from team explorer window when option Remove is always disabled?
Remove Git binding from Visual Studio 2013 solution?
This all seems like a lot of work for something that should probably be a built-in feature. The above "solutions" mention making modifications to the .git file etc.; I don't like the idea of having to change things outside of Visual Studio to affect things inside Visual Studio. Although my solution needs to make a few registry edits (and is external to VS), at least these only affect VS. Here is the work-around (read: hack):
Detailed Instructions
Be sure to have Visual Studio 2015 closed before following these steps.
1. Open regedit.exe and navigate to
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories
You might see multiple "hash" values that represent the repositories that VS is tracking.
2. Find the git repository you want to remove from the list. Look at the name
and path
values to verify the correct repository to delete:
3. Delete the key (and corresponding subkeys).
(Optional: before deleting, you can right click and choose Export to back up this key in case you make a mistake.) Now, right click on the key (in my case this is AE76C67B6CD2C04395248BFF8EBF96C7AFA15AA9
and select Delete).
4. Check that the LastUsedRepository
key points to "something else."
If the repository mapping you are trying to remove in the above steps is stored in LastUsedRepository
, then you'll need to remove this key, also. First navigate to:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\General
and delete the key LastUsedRepository
(the key will be re-created by VS if needed). If you are worried about removing the key, you can just modify the value and set it to an empty string:
When you open Visual Studio 2015 again, the git repository binding should not appear in the list anymore.