Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove git mapping in Visual Studio 2015

People also ask

How do I remove a Git repository from Visual Studio code?

To unbind your projectRight-click the project in the Project Explorer panel and then choose Source Control > Delete Repository from the context menu.

How do I delete a Git account in Visual Studio?

A: Go to the Security tab of account.microsoft.com and select Advanced security options to unlink your GitHub account. Unlinking your GitHub account removes it as a sign-in method and removes access to any GitHub repositories in Visual Studio.


The solution is much simpler than that. You simply need to remove three files from the project UNC Path.

Navigate to your solution's UNC Path.

Example: C:\Users\Your User Name\Documents\Visual Studio 2015\Projects\Your Project Folder

Then permanently delete ("SHIFT + DEL") the .git* files and folder. There are two files and one folder, which may be hidden so ensure you have your folders and search options > View > show hidden files, folder, and drives (Radio Button) Selected.

The files to permanently delete are:

.gitignore (file)

.gitattributes (file)

.git (folder)

Reopen Visual Studio and there is no more relationship to the Git Source Control. If you wanted to take it as far as removing it from the registry as mentioned above, you could, but that shouldn't be necessary aside from the "house keeping" of your machine.


Tools -> Options -> Source Control -> Current Source Control Plug-in: None


Short Version

  1. Remove the appropriate entr(y|ies) under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\GitSourceControl\Repositories.

  2. 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

Regedit repositories for VS

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:

verify repo 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

location of general key

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:

delete last used repo

When you open Visual Studio 2015 again, the git repository binding should not appear in the list anymore.


A Git repository can be removed from the Local Git Repositories list in VS-2015 when it is no longer the active project.

Your screen shot has only have one repository present, and it is active, so you can't remove it.

When you have two or more repositories, one of them will be shown in BOLD representing the active repository. Other non-active repositories can, at that time, be removed.

So, to solve your problem, if you connect with a second local repository, you will be able to remove the one you are highlighting in your screen shot.

Unfortunately, Team Explorer seems to always keep one repository active. Not sure how to convince it to let go altogether without switching to another repository.


Removing .git hidden folder worked for me.


  1. Navigate to your project directory
  2. Click on the folder Menu-> Tools-> Folder options
  3. Select the View-tab
  4. Select Under File and Folders the Show hidden files, folder, and drives
  5. Click OK
  6. Delete the .git folder
  7. Close and re-open you Visual Studio
  8. Open your project
  9. Done. :)

Safe coding.


The above answer did not work for me. The registry entries would just be automatically re-added when I opened the solution in Visual Studio. I found the resolution in one of the links in Matthews answer though so credit still goes to him for the correct answer.

Remove Git binding from Visual Studio 2013 solution?

Remove the hidden .git folder in your solutionfolder.

I also removed the .gitattributes and .gitignore files just to keep my folder clean.